Publish webservice on SAP PO – Part 2

Hello everyone!

In previous post, I showed you how to configure interface in Enterprise Service Repository (ESR).

you can read that post again at link: PUBLISH WEBSERVICE ON SAP PO – PART 1

In this post, I will show you how to coding on SAP ERP to apply logic process data based on input paramters of interface SI_Material_Receiver.

Goto TCode: SProxy

Go to Source \ ESR \ SWCs \ Namespaces \ <Your namespace>

Generate Service Providers which created in ESR : SI_Material_Receiver

When generate Service Provider SI_Material_Receiver , System will automatic generate  Implemeneting Class ZCL_SI_MATERIAL_RECEIVER. Double click on this class

Double click on method SI_MATERIAL_RECEIVER

You need to put your coding here.

Flow scenarios get detail of material, please refer my snipping code:

(This is my example, you can put your own logic code)

TYPESBEGIN OF ty_output,
             matnr TYPE mara-matnr,
             maktx TYPE makt-maktx,
             meins TYPE mara-meins,
             stprs TYPE mbew-stprs,
           END OF ty_output.

    DATAlt_input    TYPE zdt_material_input_list_tab,
          wa_input    TYPE zdt_material_input_list,

          lt_output   TYPE TABLE OF ty_output,
          wa_output   TYPE ty_output,

          wa_list_out TYPE zdt_material_output_list,
          lt_list_out TYPE zdt_material_output_list_tab,

          lt_matnr    TYPE TABLE OF mara,
          wa_matnr    TYPE mara.

    lt_input input-mt_material_input-list.
    LOOP AT lt_input INTO wa_input.
      CLEAR wa_matnr.
      wa_matnr-matnr wa_input-matnr.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
        EXPORTING
          input        wa_matnr-matnr
        IMPORTING
          output       wa_matnr-matnr
        EXCEPTIONS
          length_error 1
          OTHERS       2.
      IF sy-subrc <> 0.
      ENDIF.
      APPEND wa_matnr TO lt_matnr.
    ENDLOOP.

    SELECT mara~matnrmakt~maktxmara~meinsmbew~stprs
      FROM mara
        LEFT OUTER JOIN mbew ON mara~matnr EQ mbew~matnr
        INNER JOIN makt ON mara~matnr EQ makt~matnr
      INTO CORRESPONDING FIELDS OF TABLE @lt_output
        FOR ALL ENTRIES IN @lt_matnr
        WHERE mara~matnr @lt_matnr-matnr
        AND   makt~spras 'E'
        AND   mbew~bwkey '****'. "this value based on your system

    IF lt_output[] IS INITIAL.
      wa_list_out-matnr 'N/A'.
      wa_list_out-maktx 'Not found'.
      APPEND wa_list_out TO lt_list_out.
    ELSE.
      LOOP AT lt_output INTO wa_output.
        CLEAR wa_list_out.
        CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
          EXPORTING
            input         wa_output-matnr
         IMPORTING
           OUTPUT        wa_output-matnr.

        wa_list_out-matnr wa_output-matnr.
        wa_list_out-maktx wa_output-maktx.
        wa_list_out-meins wa_output-meins.
        wa_list_out-stprs wa_output-stprs.
        APPEND wa_list_out TO lt_list_out.
      ENDLOOP.
    ENDIF.
    output-mt_material_output-list lt_list_out.

Now, active your change in class.

You have completed apply business logic on SAP ERP system, in next post, I will show you how to configure integration builder to publish webservice to outside.

Thank you!

Giang

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.