Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

upload GL accounts

Hi,

Can anybody tell me how to upload GL Accounts in 'FB01' transaction using call transaction method. The program should update the database for success records and it should create a session for error records so that the end user can enter those records in foreground.

Thanks & Regards

SSA.

Former Member
Former Member replied

You can use the program RFBIBL00 to upload the FI documents.

Try to read the documentation of RFBIBL00, you will get better idea.

You have to fill the requried data in BBKPF per document and BBSEG per document line items.

I have attached code for yr reference.

File Format : Below listed fields must be filled when you wnat to post new document. Program will recognize new document by itab-newdoc = 'X'.

NEWDOC , "New Doc

BLDAT(10) , "Doc Date

BUDAT(10) , "Posting Date

BLART(2) , "Document Type

XBLNR LIKE BKPF-XBLNR , "Refrence

BKTXT LIKE BKPF-BKTXT , "Doc Header Text

You need one serverfile. After sucessfully run of program you have to run the progrma RFBIBL00. Pass data transfer type = 'B'.

Regards,

Naimesh.

PS: Reward points, if it is useful..!

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

REPORT ZTEST_NP .

          • Tables

TABLES: BSEG ,

BGR00,

BBKPF,

BBSEG,

t001.

          • Internal Tables

DATA: BEGIN OF ITAB OCCURS 0 ,

NEWDOC , "New Doc

BLDAT(10) , "Doc Date

BUDAT(10) , "Posting Date

BLART(2) , "Document Type

XBLNR LIKE BKPF-XBLNR , "Refrence

BKTXT LIKE BKPF-BKTXT , "Doc Header Text

BSCHL(2) , "Posting Key

HKONT(10) , "Account

UMSKZ(1), "Sp GL ind

ZLSCH(1) , "Payment Method

ZLSPR(1) , "Payment Block

WRBTR(16), "Amount without sign

KOSTL(10), "Cost center

GSBER(4) , "Business Area

ZUONR LIKE BSEG-ZUONR , "Assignment

AUFNR LIKE BSEG-AUFNR , "Order

PERNR(8) , "Personal Number

SGTXT LIKE BSEG-SGTXT, "Line Item Text

END OF ITAB .

DATA: ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.

DATA: I_BBKPF LIKE BBKPF OCCURS 0 WITH HEADER LINE.

DATA: I_BBSEG LIKE BBSEG OCCURS 0 WITH HEADER LINE.

DATA: I_BWITH LIKE BWITH OCCURS 0 WITH HEADER LINE.

          • Data Declaration

DATA: C_NODATA(1) TYPE C VALUE '/',

W_CNT TYPE I.

FIELD-SYMBOLS <F>.

SELECTION-SCREEN: BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-T01.

PARAMETER: P_BUKRS LIKE BKPF-BUKRS OBLIGATORY,

PSESSION(12) OBLIGATORY DEFAULT 'Auto_FI',

P_SFILE LIKE RLGRAP-FILENAME OBLIGATORY ,

P_LFILE LIKE RLGRAP-FILENAME OBLIGATORY .

SELECTION-SCREEN: END OF BLOCK BLK1.

          • At Selection Screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LFILE.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

FILE_NAME = P_LFILE.

          • Start Of Selection

START-OF-SELECTION .

OPEN DATASET P_SFILE FOR OUTPUT IN TEXT MODE .

PERFORM INIT_BGR00 USING C_NODATA.

PERFORM INIT_IBKPF USING C_NODATA.

PERFORM INIT_IBSEG USING C_NODATA.

PERFORM UPLOAD .

PERFORM SET_DATA.

&----


*& Form INIT_BGR00

&----


FORM INIT_BGR00 USING NODATA .

CLEAR BGR00.

BGR00-STYPE = '0'.

BGR00-GROUP = PSESSION.

BGR00-MANDT = SY-MANDT .

BGR00-USNAM = SY-UNAME .

  • bgr00-start = datum .

BGR00-XKEEP = 'X'.

BGR00-NODATA = NODATA.

TRANSFER BGR00 TO P_SFILE.

ENDFORM. " INIT_BGR00

&----


*& Form INIT_IBKPF

&----


FORM INIT_IBKPF USING NODATA .

  • Initialize data fields with NODATA:

W_CNT = 0.

DO.

ADD 1 TO W_CNT.

ASSIGN COMPONENT W_CNT OF STRUCTURE I_BBKPF TO <F>.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

MOVE NODATA TO <F>.

ENDDO.

ENDFORM.

&----


*& Form INIT_IBSEG

&----


FORM INIT_IBSEG USING NODATA.

  • Initialize data fields with NODATA:

W_CNT = 0.

DO.

ADD 1 TO W_CNT.

ASSIGN COMPONENT W_CNT OF STRUCTURE I_BBSEG TO <F>.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

MOVE NODATA TO <F>.

ENDDO.

ENDFORM.

&----


*& Form INIT_BBKPF

&----


FORM INIT_BBKPF.

MOVE I_BBKPF TO BBKPF.

BBKPF-STYPE = '1'.

ENDFORM. " INIT_BBKPF

&----


*& Form INIT_BBSEG

&----


FORM INIT_BBSEG.

MOVE I_BBSEG TO BBSEG.

BBSEG-STYPE = '2'.

BBSEG-TBNAM = 'BBSEG'.

ENDFORM. " INIT_BBSEG

&----


*& Form UPLOAD

&----


FORM UPLOAD.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_LFILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

OTHERS = 8.

IF SY-SUBRC NE 0 .

MESSAGE S001(01) WITH 'The File Could not be Uploaded..!' .

LEAVE LIST-PROCESSING .

ELSE.

DELETE ITAB INDEX 1 .

ENDIF .

LOOP AT ITAB .

DO .

REPLACE '.' WITH '' INTO ITAB-BLDAT .

IF SY-SUBRC NE 0 .

CONDENSE ITAB-BLDAT NO-GAPS .

EXIT .

ENDIF .

ENDDO .

DO .

REPLACE '.' WITH '' INTO ITAB-BUDAT .

IF SY-SUBRC NE 0 .

CONDENSE ITAB-BUDAT NO-GAPS .

EXIT .

ENDIF .

ENDDO .

MODIFY ITAB .

ENDLOOP .

ENDFORM. " UPLOAD

&----


*& Form SET_DATA

&----


FORM SET_DATA.

DATA: L_DOCCNT TYPE I,

L_LNCNT TYPE I .

SELECT SINGLE * FROM T001

WHERE BUKRS = P_BUKRS.

LOOP AT ITAB .

IF ITAB-NEWDOC = 'X' OR ITAB-NEWDOC = 'x' .

CLEAR : L_LNCNT .

L_DOCCNT = L_DOCCNT + 1.

PERFORM INIT_BBKPF .

BBKPF-TCODE = 'FB01'.

BBKPF-BUKRS = P_BUKRS.

WRITE : ITAB-BLDAT DD/MM/YY TO BBKPF-BLDAT.

WRITE : ITAB-BUDAT DD/MM/YY TO BBKPF-BUDAT.

BBKPF-BLART = ITAB-BLART .

BBKPF-WAERS = T001-WAERS.

BBKPF-BKTXT = ITAB-BKTXT .

BBKPF-XBLNR = ITAB-XBLNR .

TRANSFER BBKPF TO P_SFILE.

ENDIF .

L_LNCNT = L_LNCNT + 1 .

IF L_LNCNT GT 990 .

MESSAGE S001(01) WITH 'Number of Records Exceed 990 Line Items'

'Program cannot be executed' .

LEAVE LIST-PROCESSING .

ENDIF .

PERFORM INIT_BBSEG .

BBSEG-NEWKO = ITAB-HKONT .

BBSEG-NEWBS = ITAB-BSCHL .

BBSEG-WRBTR = ITAB-WRBTR .

IF NOT ITAB-KOSTL IS INITIAL .

BBSEG-KOSTL = ITAB-KOSTL .

ELSE .

IF NOT ITAB-GSBER IS INITIAL .

BBSEG-GSBER = ITAB-GSBER .

ENDIF .

ENDIF .

BBSEG-ZUONR = ITAB-ZUONR.

BBSEG-SGTXT = ITAB-SGTXT .

IF NOT ITAB-AUFNR IS INITIAL .

BBSEG-AUFNR = ITAB-AUFNR .

ENDIF .

IF NOT ITAB-UMSKZ IS INITIAL .

BBSEG-NEWUM = ITAB-UMSKZ .

ENDIF .

IF ITAB-BSCHL = '29' OR ITAB-BSCHL = '39' OR ITAB-BSCHL = '09' .

BBSEG-ZFBDT = BBKPF-BLDAT .

ENDIF .

IF NOT ITAB-ZLSCH IS INITIAL .

BBSEG-ZLSCH = ITAB-ZLSCH .

ENDIF .

IF NOT ITAB-PERNR IS INITIAL .

BBSEG-PERNR = ITAB-PERNR .

ENDIF .

IF NOT ITAB-ZLSPR IS INITIAL .

BBSEG-ZLSPR = ITAB-ZLSPR .

ENDIF .

TRANSFER BBSEG TO P_SFILE.

ENDLOOP .

IF L_DOCCNT NE 0 .

WRITE :/ P_SFILE , 'has been created' .

WRITE :/ L_DOCCNT , 'DOCUMENTS UPLOADED' .

ELSE .

WRITE :/'INPUT FILE CONTAINS NO DATA' .

ENDIF .

CLOSE DATASET P_SFILE .

ENDFORM. " SET_DATA

POSTING_INTERFACE_DOCUMENT

Urgent!!!need help with posting GL accounts

Please give me reward points if it is useful...

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question