Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FB01 Data

Former Member
0 Likes
412

Hi

Any one can send me the code for FB01 data upload using BDC

Thanks in Advance

2 REPLIES 2
Read only

Former Member
0 Likes
364

Hi,

Hope this will help you. In this session method is used.

*---- Data definition -


DATA: BEGIN OF BDCDATA OCCURS 5.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

DATA: C_TCODE LIKE BKPF-TCODE VALUE 'FB01'.

DATA BEGIN OF MESSTAB OCCURS 10.

INCLUDE STRUCTURE BDCMSGCOLL.

DATA END OF MESSTAB.

**********************************************************************

*---- Call transaction -


FORM Main_Program

REFRESH BDCDATA.

PERFORM APPEND_BDC USING 'SAPMF05A' '0100' ' ' ' '.

PERFORM APPEND_BDC USING ' ' ' ' 'BKPF-BLDAT' '09031998'.

PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' '/00'.

PERFORM APPEND_BDC USING 'SAPMF05A' '0300' ' ' ' '.

PERFORM APPEND_BDC USING ' ' ' ' 'BSEG-WRBTR' '*'.

PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' 'BU'.

CALL TRANSACTION 'FB01' USING BDCDATA MODE 'N' UPDATE 'S'.

ENDFORM.

**********************************************************************

*--- Call transaction with errors to BDC -


REFRESH MESSTAB.

CALL TRANSACTION C_TCODE USING BDCDATA MODE 'N' UPDATE 'S'

MESSAGES INTO MESSTAB.

RETURN_CODE = SY-SUBRC.

IF RETURN_CODE = 0.

LOOP AT MESSTAB.

IF MESSTAB-MSGTYP = 'E'.

RETURN_CODE = MESSTAB-MSGNR.

SY-MSGID = 'B1'.

SY-MSGNO = 999.

SY-MSGV1 = 'Error: Check BDC'.

ENDIF.

ENDLOOP.

ENDIF.

*--- Here we check the return code, if there was an error, we put the

  • transaction in a BDC session for the user to review and correct.

IF RETURN_CODE NE 0.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ZW'

USER = SY-UNAME

KEEP = 'X'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = C_TCODE

TABLES

DYNPROTAB = BDCDATA.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.

ENDIF.

**********************************************************************

*--- Append BDCDATA internal table -


FORM APPEND_BDC USING VALUE(P_PROG)

VALUE(P_SCREEN)

VALUE(P_NAM)

VALUE(P_VAL).

CLEAR BDCDATA.

IF P_PROG NE SPACE.

BDCDATA-PROGRAM = P_PROG.

BDCDATA-DYNPRO = P_SCREEN.

BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = P_NAM.

BDCDATA-FVAL = P_VAL.

ELSE.

BDCDATA-FNAM = P_NAM.

BDCDATA-FVAL = P_VAL.

ENDIF.

APPEND BDCDATA.

ENDFORM.

Reward if helpful.

Read only

Former Member
0 Likes
364

copy and paste of code will not fulfill ur requirement .

first do recording in ur system , then from that recording create a sample program , there after u can change that program as per ur requirement.

checK sm35 -> create recording-> change recording--->come out of recording.then SM35 screen u will get option to create program --->click that one.

Regards

Prabhu