Sample Code Abap BDC for Upload GL Account TCODE FS00 without LSMW | ILMU PROGRAMMER
Home » Sample Code Abap BDC for Upload GL Account TCODE FS00 without LSMW

Sample Code Abap BDC for Upload GL Account TCODE FS00 without LSMW

Hai, Tcode FS00 merupakan tcode untuk membuat master data GL Account, kali ini saya akan membagikan code program ABAP untuk upload master data GL Account tsb (Versi bukan LSMW)

Langkah pertama, karena saya menggunakan Z table untuk menampung data yang akan di upload, buat table terlebih dahulu ya:

Berikut merupakan code program lengkapnya:

*&---------------------------------------------------------------------*
*& Report ZFS00
*&---------------------------------------------------------------------*
*& ILMUPROGRAM.COM
*& WAHYU AMALDI, M.KOM
*&---------------------------------------------------------------------*
REPORT zfs00.
"MESSAGE-ID ..
CONSTANTS: gc_abap_true TYPE char1 VALUE 'X',
           gc_nodata    VALUE '/'.              "gc_nodata
DATA : ld_int        TYPE i,
       ld_split1(20), ld_split2(20), ld_split3(20).
"----------------- bdc
DATA: gt_bdcdata  TYPE TABLE OF bdcdata,
      ls_bdcdata  TYPE bdcdata,
      ld_ebeln    TYPE ebeln,
      lt_output   TYPE string_table,
      ls_msg(200) TYPE c,
      ld_dismode  TYPE ctu_mode.

DATA: lt_line   TYPE TABLE OF tline,
      ls_line   TYPE tline,
      ls_head   TYPE thead,
      ld_tdname LIKE thead-tdname.

DATA: ld_format_date1 TYPE c LENGTH 10,
      ld_format_date2 TYPE c LENGTH 10,
      ld_format_date3 TYPE c LENGTH 10.
DATA: lt_ztbfi_fs00 TYPE TABLE OF ztbfi_fs00 WITH HEADER LINE.
SELECT * FROM ztbfi_fs00
  INTO TABLE lt_ztbfi_fs00.

LOOP AT lt_ztbfi_fs00.
  Refresh: gt_bdcdata[].
  PERFORM bdc_dynpro      USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN'                '2001'.
  PERFORM bdc_field       USING: 'BDC_OKCODE'              '=ACC_CRE',
        'GLACCOUNT_SCREEN_KEY-SAKNR' lt_ztbfi_fs00-saknr,
        'GLACCOUNT_SCREEN_KEY-BUKRS' lt_ztbfi_fs00-bukrs.

  PERFORM bdc_dynpro      USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN'                '2001'.
  PERFORM bdc_field       USING: 'BDC_OKCODE'              '=2102_GROUP',
        'GLACCOUNT_SCREEN_COA-KTOKS'         lt_ztbfi_fs00-ktoks,
        'GLACCOUNT_SCREEN_COA-XBILK'       'X'.

  PERFORM bdc_dynpro      USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN'                '2001'.
  PERFORM bdc_field       USING: 'BDC_OKCODE'              '=TAB02',
        'GLACCOUNT_SCREEN_COA-KTOKS'         lt_ztbfi_fs00-ktoks,
        'GLACCOUNT_SCREEN_COA-XBILK'       'X',
        'GLACCOUNT_SCREEN_COA-TXT20_ML'         lt_ztbfi_fs00-txt20,
        'GLACCOUNT_SCREEN_COA-TXT50_ML'         lt_ztbfi_fs00-txt50.

  PERFORM bdc_dynpro      USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN'                '2001'.
  PERFORM bdc_field       USING: 'BDC_OKCODE'              '=TAB03',
        'GLACCOUNT_SCREEN_CCODE-WAERS'         'IDR',
        'GLACCOUNT_SCREEN_CCODE-XKRES'       'X'.

  PERFORM bdc_dynpro      USING 'SAPLGL_ACCOUNT_MASTER_MAINTAIN'                '2001'.
  PERFORM bdc_field       USING: 'BDC_OKCODE'              '=SAVE',
        'GLACCOUNT_SCREEN_CCODE-FSTAG'         lt_ztbfi_fs00-fstag,
        'GLACCOUNT_SCREEN_CCODE-XGKON'       'X',
        'GLACCOUNT_SCREEN_CCODE-HBKID'         lt_ztbfi_fs00-hbkid,
        'GLACCOUNT_SCREEN_CCODE-HKTID'        lt_ztbfi_fs00-hktid.
  ld_dismode = 'N'.
  PERFORM f_bdc_transaction USING 'FS00'.
ENDLOOP.

* INCLUDE LYINTERFACE_FG02D...               " Local class definition

*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR ls_bdcdata.

  ls_bdcdata-program  = program.
  ls_bdcdata-dynpro   = dynpro.
  ls_bdcdata-dynbegin = 'X'.
  APPEND ls_bdcdata TO gt_bdcdata.
ENDFORM.                    "BDC_DYNPRO

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  DATA: ls_value TYPE string.

  ls_value = fval.

  IF ls_value <> gc_nodata.
    CLEAR ls_bdcdata.

    ls_bdcdata-fnam = fnam.
    ls_bdcdata-fval = fval.
    APPEND ls_bdcdata TO gt_bdcdata.
  ENDIF.
ENDFORM.                    "BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  F_BDC_TRANSACTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0055   text
*----------------------------------------------------------------------*
FORM f_bdc_transaction  USING  p_tcode.
  DATA : lt_messtab TYPE TABLE OF bdcmsgcoll,
         ls_params  TYPE ctu_params,
         lt_message TYPE TABLE OF bapiret2,
         ls_message TYPE bapiret2,

         ld_len     TYPE i.

** Call transaction parameters

*  Modes
*  A - is all screen mode. All the screen of transaction are displayed.
*  N - is no screen mode no Screen is displayed when you executed the transaction.
*  E - is error screen Only those Screen are displayed where in you have error record.
  ls_params-dismode = ld_dismode.
  ls_params-updmode = 'S'.
  ls_params-defsize = gc_abap_true.

  REFRESH: lt_output.

  IF NOT gt_bdcdata[] IS INITIAL.
    CALL TRANSACTION p_tcode USING gt_bdcdata
          MESSAGES INTO lt_messtab[]
          OPTIONS FROM ls_params.

    CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2'
      TABLES
        imt_bdcmsgcoll = lt_messtab[]
        ext_return     = lt_message.
*
    LOOP AT lt_message INTO ls_message.
      CONCATENATE '[' ls_message-type ']' INTO ls_msg.
      CONCATENATE ls_msg ls_message-message INTO ls_msg SEPARATED BY space.

      APPEND ls_msg TO lt_output.
    ENDLOOP.
  ENDIF.

  CLEAR gt_bdcdata[].
ENDFORM.                    " F_BDC_TRANSACTION

Semoga membantu

Leave a Comment

 
Open chat
Perlu Bantuan Konsultasi ?
Hallo Pembaca.
Telp (021) 55670115 untuk terhubung langsung dengan kami.

Apakah ada yang bisa kami bantu?