We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

[sap-dev] BAPI for FB50

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Posted by arif_mohd_ali (SAP)
on Sep 6 at 2:59 AM
Dear All,
I try to check the BAPI and used the FM BAPI_ACC_GL_POSTING_POST for posting the Gl account, the message shows document posted successfully, but how to know... Document posted with which document number its show the message "Document posted successfully: IDOC TEST000001BAPICALL ALE110".

And anyone can help me.. How to get the document number form the posted document or is I m missing anything.


Here is my code.
DATA : DOCUMENT_HEADER LIKE BAPIACHE08,
GL_DATA LIKE BAPIACGL08 OCCURS 100 WITH HEADER LINE,
CURR_AMT LIKE BAPIACCR08 OCCURS 100 WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 100 WITH HEADER LINE,
EXTENSION LIKE BAPIEXTC OCCURS 100 WITH HEADER LINE.

DATA : OBJ_TYPE LIKE BAPIACHE02-OBJ_TYPE,
OBJ_KEY LIKE BAPIACHE02-OBJ_KEY,
OBJ_SYS LIKE BAPIACHE02-OBJ_SYS.

DATA: L_BAPIRET2 LIKE BAPIRET2,
L_MSG LIKE BAPIRET2-MESSAGE.

TYPES: BEGIN OF T_MESSAGE,
CUSNO(10),
REDOC LIKE BSID-XBLNR, "Reference document number
ID(2) TYPE N,
MSGTYP(1),
MESSAGE(100),
MSGID(20),
END OF T_MESSAGE.

DATA I_MESSAGE TYPE T_MESSAGE OCCURS 100 WITH HEADER LINE.

START-OF-SELECTION.
DOCUMENT_HEADER-OBJ_TYPE = 'IDOC'.
DOCUMENT_HEADER-OBJ_KEY = 'TEST000001BAPICALL'.
DOCUMENT_HEADER-OBJ_SYS = 'ALE110'.
DOCUMENT_HEADER-USERNAME = SY-UNAME.
"document_header-BUS_ACT = 'RFBU'.
DOCUMENT_HEADER-COMP_CODE = '1000'.
DOCUMENT_HEADER-DOC_DATE = SY-DATUM.
DOCUMENT_HEADER-PSTNG_DATE = SY-DATUM.
DOCUMENT_HEADER-FISC_YEAR = SY-DATUM+0(4).
DOCUMENT_HEADER-FIS_PERIOD = SY-DATUM+4(2).
DOCUMENT_HEADER-DOC_TYPE = 'SA'.

GL_DATA-ITEMNO_ACC = '0001'.
GL_DATA-GL_ACCOUNT = '0000640390'.
GL_DATA-COMP_CODE = '1000'.
GL_DATA-PSTNG_DATE = SY-DATUM.
GL_DATA-DOC_TYPE = 'SA'.
"gl_data-AC_DOC_NO
GL_DATA-FISC_YEAR = SY-DATUM+0(4).
GL_DATA-FIS_PERIOD = SY-DATUM+4(2).
GL_DATA-STAT_CON = 'H'.
"gl_data-BUS_AREA
GL_DATA-COSTCENTER = '1DTHN01'.
APPEND GL_DATA.

CURR_AMT-ITEMNO_ACC = '0001'.
CURR_AMT-CURR_TYPE = '00'.
CURR_AMT-CURRENCY = 'THB'.
CURR_AMT-AMT_DOCCUR = '100.00'.
APPEND CURR_AMT.

GL_DATA-ITEMNO_ACC = '0002'.
GL_DATA-GL_ACCOUNT = '0000640830'.
GL_DATA-COMP_CODE = '1000'.
GL_DATA-PSTNG_DATE = SY-DATUM.
GL_DATA-DOC_TYPE = 'SA'.
"gl_data-AC_DOC_NO
GL_DATA-FISC_YEAR = SY-DATUM+0(4).
GL_DATA-FIS_PERIOD = SY-DATUM+4(2).
GL_DATA-STAT_CON = 'H'.
"gl_data-BUS_AREA
GL_DATA-COSTCENTER = '1DTHN01'.
APPEND GL_DATA.

CURR_AMT-ITEMNO_ACC = '0002'.
CURR_AMT-CURR_TYPE = '00'.
CURR_AMT-CURRENCY = 'THB'.
CURR_AMT-AMT_DOCCUR = '100.00'.
APPEND CURR_AMT.


CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
DOCUMENTHEADER = DOCUMENT_HEADER
IMPORTING
OBJ_TYPE = OBJ_TYPE
OBJ_KEY = OBJ_KEY
OBJ_SYS = OBJ_SYS
TABLES
ACCOUNTGL = GL_DATA
CURRENCYAMOUNT = CURR_AMT
RETURN = RETURN
* EXTENSION1 = exten
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
* IMPORTING
* RETURN =.

IF NOT RETURN[] IS INITIAL.
LOOP AT RETURN.
WRITE :/ RETURN-MESSAGE,RETURN-MESSAGE_V1,RETURN-MESSAGE_V2,RETURN-MESSAGE_V3,RETURN-MESSAGE_V4,RETURN-PARAMETER.
ENDLOOP.
ENDIF.

__.____._
Copyright © 2010 Toolbox.com and message author.

Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
Related Content
White Papers

In the Spotlight
Toolbox.com for iPhone: Ask Questions & Get Answers Anywhere. Use the New iPhone App
_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language