Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125
Beginner

BDC Using Session Method

*&———————————————————————*
*& Report  ZTEST_BDC_FI01_1
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ztest_bdc_fi01_1.

typesbegin of ty_error,
msg type string,
lineno type i,
end of ty_error.

*       Batchinputdata of single transaction
DATA:   bdcdata LIKE bdcdata    OCCURS WITH HEADER LINE.
PARAMETERS p_data TYPE ibipparmspath.

DATA it_tab TYPE truxs_t_text_data,
lv_filename TYPE rlgrapfilename,
it_msg type table of bdcmsgcoll,
lv_msg type string,
lt_error type table of ty_error,
ls_error type ty_error.

TYPESBEGIN OF record,
* data element: BANKS
banks(003),
* data element: BANKK
bankl(015),
* data element: BANKA
banka(060),
* data element: REGIO
provz(003),
* data element: ORT01_GP
ort01(035),
* data element: BRNCH
brnch(040),
** data element: BANKA
*        banka_007(060),
** data element: REGIO
*        provz_008(003),
** data element: ORT01_GP
*        ort01_009(035),
** data element: BRNCH
*        brnch_010(040),
END OF record.

DATAlt_record TYPE STANDARD TABLE OF record,
ls_record TYPE record.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_data.
CALL FUNCTION ‘F4_FILENAME’
EXPORTING
program_name  systcprog
dynpro_number systdynnr
field_name    ‘P_DATA’
IMPORTING
file_name     p_data.

START-OF-SELECTION.
” converting the file data into internal table
lv_filename p_data.
” CSV
CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’
EXPORTING
i_field_seperator    ‘X’
i_line_header        ‘X’
i_tab_raw_data       it_tab
i_filename           lv_filename
TABLES
i_tab_converted_data lt_record
EXCEPTIONS
conversion_failed    1
OTHERS               2.
IF sysubrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION ‘BDC_OPEN_GROUP’
EXPORTING
CLIENT                    symandt
GROUP                     ‘AKS’
KEEP                      =  abap_true
EXCEPTIONS
CLIENT_INVALID            1
DESTINATION_INVALID       2
GROUP_INVALID             3
GROUP_IS_LOCKED           4
HOLDDATE_INVALID          5
INTERNAL_ERROR            6
QUEUE_ERROR               7
RUNNING                   8
SYSTEM_LOCK_ERROR         9
USER_INVALID              10
OTHERS                    11
.
IF sysubrc <> 0.
* Implement suitable error handling here
ENDIF.

LOOP AT lt_record INTO ls_record.

PERFORM bdc_dynpro      USING ‘SAPMF02B’ ‘0100’.
PERFORM bdc_field       USING ‘BDC_CURSOR’
‘BNKABANKL’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘/00’.
PERFORM bdc_field       USING ‘BNKABANKS’
ls_recordbanks.
PERFORM bdc_field       USING ‘BNKABANKL’
ls_recordbankl.
PERFORM bdc_dynpro      USING ‘SAPMF02B’ ‘0110’.
PERFORM bdc_field       USING ‘BDC_CURSOR’
‘BNKABRNCH’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘/00’.
PERFORM bdc_field       USING ‘BNKABANKA’
ls_recordbanka.
PERFORM bdc_field       USING ‘BNKAPROVZ’
ls_recordprovz.
PERFORM bdc_field       USING ‘BNKAORT01′
ls_recordort01.
PERFORM bdc_field       USING ‘BNKABRNCH’
ls_recordbrnch.
PERFORM bdc_dynpro      USING ‘SAPMF02B’ ‘0110’.
PERFORM bdc_field       USING ‘BDC_CURSOR’
‘BNKABANKA’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘=UPDA’.
PERFORM bdc_field       USING ‘BNKABANKA’
ls_recordbanka.
PERFORM bdc_field       USING ‘BNKAPROVZ’
ls_recordprovz.
PERFORM bdc_field       USING ‘BNKAORT01′
ls_recordort01.
PERFORM bdc_field       USING ‘BNKABRNCH’
ls_recordbrnch.

CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE                  ‘FI01’
*   POST_LOCAL             = NOVBLOCAL
*   PRINTING               = NOPRINT
*   SIMUBATCH              = ‘ ‘
*   CTUPARAMS              = ‘ ‘
TABLES
dynprotab              bdcdata[]
EXCEPTIONS
INTERNAL_ERROR         1
NOT_OPEN               2
QUEUE_ERROR            3
TCODE_INVALID          4
PRINTING_INVALID       5
POSTING_INVALID        6
OTHERS                 7
.
IF sysubrc <> 0.
* Implement suitable error handling here
ENDIF.

*    CALL TRANSACTION ‘FI01’USING bdcdata MODE ‘A’ MESSAGES INTO it_msg.

CLEARbdcdata[],bdcdata ,ls_record.
ENDLOOP.

CALL FUNCTION ‘BDC_CLOSE_GROUP’
EXCEPTIONS
NOT_OPEN          1
QUEUE_ERROR       2
OTHERS            3
.
IF sysubrc <> 0.
* Implement suitable error handling here
ENDIF.

*     loop at it_msg into data(ls_msg).
*      CALL FUNCTION ‘FORMAT_MESSAGE’
*       EXPORTING
**         ID              = SY-MSGID
**         LANG            = ‘-D’
*         NO              = ls_msg-MSGNr
*         V1              =  ls_msg-MSGV1
*         V2              =  ls_msg-MSGV2
*         V3              =  ls_msg-MSGV3
*         V4              =  ls_msg-MSGV4
*       IMPORTING
*         MSG             = lv_msg
*       EXCEPTIONS
*         NOT_FOUND       = 1
*         OTHERS          = 2
*                .
*      IF sy-subrc eq 0.
** Implement suitable error handling here
*      ls_error-msg = lv_msg.
*      ls_error-lineno = sy-tabix.
*      append ls_Error to lt_error.
*      ENDIF.
*
*    endloop.
*
*    loop at lt_error into ls_error.
*      write : / ls_error-lineno, ls_error-msg.
*    ENDLOOP.
*

*———————————————————————-*
*        Start new screen                                              *
*———————————————————————-*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdataprogram  program.
bdcdatadynpro   dynpro.
bdcdatadynbegin ‘X’.
APPEND bdcdata.
ENDFORM.

*———————————————————————-*
*        Insert field                                                  *
*———————————————————————-*
FORM bdc_field USING fnam fval.
*  IF FVAL <> NODATA.
CLEAR bdcdata.
bdcdatafnam fnam.
bdcdatafval fval.
APPEND bdcdata.
*  ENDIF.
ENDFORM.

Related Questions

Leave an answer

Leave an answer