quarta-feira, 22 de julho de 2020

Selecionar itens de contratos pendentes - utilizando classe da transação SDV3

  METHOD get_analise_contrato.

    DATAlt_fieldlist TYPE tdt_fieldname,
          lt_message   TYPE tdt_sdoc_msg,
          lt_field_sel TYPE tdt_fieldname.

    DATAls_selcrit TYPE tds_sdoc_selcrit,
          ls_it_cont TYPE tp_it_cont.

    DATAlo_data TYPE REF TO data,
          lo_exc  TYPE REF TO cx_root.

    FIELD-SYMBOLS<lt_result> TYPE STANDARD TABLE.

    DATA lo_result_tab_type TYPE REF TO cl_abap_tabledescr.

    REFRESH et_it_cont.

    ls_selcrit-vbeln VALUE #sign 'I' option 'EQ' low i_vbeln ).
    ls_selcrit-open abap_true.

    TRY.

        DATA(lo_sdocNEW cl_sdoc_select_report_adapter(
                        iv_application_id if_sdoc_select=>co_application_id-va45nn
                        iv_trvog if_sdoc_select=>co_trvog-contract ).

        INSERT if_sdoc_adapter=>co_fieldname-bstnk INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-audat INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-auart INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-vbeln INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-ernam INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-kunnr INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-netwr INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-waerk INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-posnr INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-matnr INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-zmeng INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-vrkme INTO TABLE lt_fieldlist.
        INSERT if_sdoc_adapter=>co_fieldname-kwmeng INTO TABLE lt_fieldlist.

        lo_result_tab_type lo_sdoc->if_sdoc_adapter~get_result_table_type).
        CREATE DATA lo_data TYPE HANDLE lo_result_tab_type.

        ASSIGN lo_data->TO <lt_result>.

        lo_sdoc->execute_query(
              EXPORTING
                it_req_result_comp_name lt_fieldlist
                is_selcrit              ls_selcrit
              IMPORTING
                et_result               <lt_result>
                et_message              lt_message
                et_field_sel            lt_field_sel ).

      CATCH cx_sy_create_object_error INTO lo_exc.
        MESSAGE lo_exc->get_textTYPE 'I'.

    ENDTRY.

    IF <lt_result> IS ASSIGNED.

      LOOP AT <lt_result> ASSIGNING FIELD-SYMBOL(<ls_result>).

        CLEAR ls_it_cont.

        ASSIGN COMPONENT 'POSNR' OF STRUCTURE <ls_result> TO FIELD-SYMBOL(<l_value>).
        CHECK sy-subrc 0.
        ls_it_cont-posnr <l_value>.
        ASSIGN COMPONENT 'MATNR' OF STRUCTURE <ls_result> TO <l_value>.
        CHECK sy-subrc 0.
        ls_it_cont-matnr <l_value>.
        ASSIGN COMPONENT 'KWMENG' OF STRUCTURE <ls_result> TO <l_value>.
        CHECK sy-subrc 0.
        ls_it_cont-kwmeng <l_value>.

        APPEND ls_it_cont TO et_it_cont.

      ENDLOOP.

    ENDIF.


  ENDMETHOD.

Nenhum comentário:

Postar um comentário