Sample Code

BDC Sample code

Not a sample program but only the relevant sections of the program so that copying is easy.

* Data Declaration
    DATA: lt_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0,
          ls_bdcdata TYPE bdcdata,
          ls_msgbdc  TYPE bdcmsgcoll,
          lt_msgbdc  TYPE cfb_t_bdcmsgcoll,
          ls_options TYPE ctu_params.


* One screen and one variable
* It can be added in a subroutine as well
      ls_bdcdata-program = 'SAPMV50A'.
      ls_bdcdata-dynpro = '4104'.
      ls_bdcdata-dynbegin = abap_true.
      APPEND ls_bdcdata TO lt_bdcdata.
      CLEAR ls_bdcdata.

      ls_bdcdata-fnam = 'BDC_CURSOR'.
      ls_bdcdata-fval = 'LIKP-VBELN'.
      APPEND ls_bdcdata TO lt_bdcdata.
      CLEAR ls_bdcdata.

      ls_bdcdata-fnam = 'BDC_OKCODE'.
      ls_bdcdata-fval = '/00'.   "Enter
      APPEND ls_bdcdata TO lt_bdcdata.
      CLEAR ls_bdcdata.

      ls_bdcdata-fnam = 'LIKP-VBELN'.
      ls_bdcdata-fval = im_delivery.
      APPEND ls_bdcdata TO lt_bdcdata.
      CLEAR ls_bdcdata.

* Populate the options
      ls_options-dismode = 'N'.
      ls_options-updmode = 'S'.
      ls_options-racommit = abap_true.

* Call Transaction
      CALL TRANSACTION 'VL32N' USING lt_bdcdata
            OPTIONS FROM ls_options
            MESSAGES INTO lt_msgbdc.

* Error Handling
      IF sy-subrc = 0.

        READ TABLE lt_msgbdc INTO ls_msgbdc
              WITH KEY msgtyp = 'S'.
        IF sy-subrc = 0.
* Success
        ELSE
*Error
        ENDIF.
      ELSE.
        READ TABLE lt_msgbdc INTO ls_msgbdc
          WITH KEY msgtyp = 'S'.
        IF sy-subrc = 0.
* Success
        ELSE.
* Error
        ENDIF.
      ENDIF.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share