Master Function Imports in SAP OData Part 19



Function Import:-
so_count_by_status

Importing :-
 Customer
Exporting :-
 Customer
 NotProcesed
 CompleteProcess
 NotRelvent



*******************************************************************




    CASE  iv_action_name .
      WHEN 'get_so_status'.
        TYPES:BEGIN OF ty_tab,
               vbeln TYPE vbeln,
               kunnr TYPE kunnr,
               rfstk TYPE rfstk,
              END OF ty_tab.
        DATA: it_tab TYPE TABLE OF ty_tab,
              lv_kunnr TYPE kunnr,
              ls_count TYPE zcl_zsalesorder_001_mpc=>ts_count,
              lt_count TYPE zcl_zsalesorder_001_mpc=>tt_count.

        DATA(lt_para)  =   io_tech_request_context->get_parameters( ).

        lv_kunnr = lt_para[ 1 ]-value .
        lv_kunnr = |{ lv_kunnr ALPHA = IN } |.



        SELECT so~vbeln
               so~kunnr
               sta~rfstk
          FROM vbak AS so
          LEFT OUTER JOIN vbuk AS sta
          ON so~vbeln = sta~vbeln
          INTO TABLE it_tab
          WHERE so~kunnr = lv_kunnr.
        IF sy-subrc IS INITIAL.
          ls_count-customer = lv_kunnr.
          LOOP AT it_tab ASSIGNING FIELD-SYMBOL(<ls_tab>).
            CASE <ls_tab>-rfstk.
              WHEN 'C'.
                ls_count-completeprocess = ls_count-completeprocess + 1.
              WHEN 'A'.
                ls_count-notprocesed  = ls_count-notprocesed + 1.
              WHEN ' '.
                ls_count-notrelvent =  ls_count-notrelvent  + 1.
            ENDCASE.

          ENDLOOP.
          APPEND ls_count to lt_count.

          /iwbep/if_mgw_conv_srv_runtime~copy_data_to_ref(
            EXPORTING
              is_data = lt_count
            CHANGING
              cr_data = er_data
          ).
        ENDIF.
    ENDCASE.

Comments

Popular posts from this blog

AMDP ( ABAP Managed Database Procedure ) Part - 1

Backup all ADT Objects & Other queries RAP Part 10.1

SAP CDS Introduction Part 2 - ABAP on HANA Course