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.

types: begin of ty_error,
msg type string,
lineno type i,
end of ty_error.

*       Batchinputdata of single transaction
DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
PARAMETERS : p_data TYPE ibipparms–path.

DATA : it_tab TYPE truxs_t_text_data,
lv_filename TYPE rlgrap–filename,
it_msg type table of bdcmsgcoll,
lv_msg type string,
lt_error type table of ty_error,
ls_error type ty_error.

TYPES: BEGIN 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.

DATA: lt_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  = syst–cprog
dynpro_number = syst–dynnr
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 sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION ‘BDC_OPEN_GROUP’
EXPORTING
CLIENT                    = sy–mandt
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 sy–subrc <> 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’
‘BNKA–BANKL’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘/00’.
PERFORM bdc_field       USING ‘BNKA–BANKS’
ls_record–banks.
PERFORM bdc_field       USING ‘BNKA–BANKL’
ls_record–bankl.
PERFORM bdc_dynpro      USING ‘SAPMF02B’ ‘0110’.
PERFORM bdc_field       USING ‘BDC_CURSOR’
‘BNKA–BRNCH’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘/00’.
PERFORM bdc_field       USING ‘BNKA–BANKA’
ls_record–banka.
PERFORM bdc_field       USING ‘BNKA–PROVZ’
ls_record–provz.
PERFORM bdc_field       USING ‘BNKA–ORT01′
ls_record–ort01.
PERFORM bdc_field       USING ‘BNKA–BRNCH’
ls_record–brnch.
PERFORM bdc_dynpro      USING ‘SAPMF02B’ ‘0110’.
PERFORM bdc_field       USING ‘BDC_CURSOR’
‘BNKA–BANKA’.
PERFORM bdc_field       USING ‘BDC_OKCODE’
‘=UPDA’.
PERFORM bdc_field       USING ‘BNKA–BANKA’
ls_record–banka.
PERFORM bdc_field       USING ‘BNKA–PROVZ’
ls_record–provz.
PERFORM bdc_field       USING ‘BNKA–ORT01′
ls_record–ort01.
PERFORM bdc_field       USING ‘BNKA–BRNCH’
ls_record–brnch.

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 sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.

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

CLEAR: bdcdata[],bdcdata ,ls_record.
ENDLOOP.

CALL FUNCTION ‘BDC_CLOSE_GROUP’
EXCEPTIONS
NOT_OPEN          = 1
QUEUE_ERROR       = 2
OTHERS            = 3
.
IF sy–subrc <> 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.
bdcdata–program  = program.
bdcdata–dynpro   = dynpro.
bdcdata–dynbegin = ‘X’.
APPEND bdcdata.
ENDFORM.

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

Related Questions

Leave an answer

Leave an answer