2009 Jun 07 7:28 AM
Hi -
Can anyone suggest me or give sample code to post document thru F-30 transaction code "Post with Clearing". I need to develop a code to post the document for customer bad debit write off and i'm using F-30 transaction code...
Thanks in advance.
Rds,
Kannan
2009 Jun 07 7:52 AM
2009 Jun 07 7:54 AM
Hi
U can use BI std program RFBIBL00: F-30 is based on transaction FB05 supported by rfbibl00.
The file for rfbibl00 has to be based on following structures:
BGR00: session data
BBKPF: header data for clearing document
BBSEG: Item data for clearing document
BSELK: to indicate which header fields to be used for open items selection
BBSELP: to indicate which ITEM fields to be used for open items selection
Here my code used to clear open vendor items without a clearing document (so I don't use BBSEG structure):
DATA: BEGIN OF BREAK,
BUKRS LIKE BSIK-BUKRS,
LIFNR LIKE BSIK-LIFNR,
UMSKZ LIKE BSIK-UMSKZ,
ZUONR LIKE BSIK-ZUONR,
WAERS LIKE BSIK-WAERS,
END OF BREAK.
DATA: OLD_BREAK LIKE BREAK.
LOOP AT T_BSIK INTO BSIK.
IF OPEN_FILE = SPACE AND P_TEST = SPACE.
OPEN_FILE = 'X'.
* Open file
OPEN DATASET ZFAGTB01-FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
* Set session data
PERFORM FILL_NO_DATA USING BGR00 'BGR00'.
BGR00-STYPE = '0'.
BGR00-GROUP = <session name>.
BGR00-MANDT = SY-MANDT.
BGR00-USNAM = SY-UNAME.
BGR00-START = SPACE.
BGR00-XKEEP = 'X'.
BGR00-NODATA = '/'.
TRANSFER BGR00 TO P_FILENAME.
ENDIF.
* Movimento dati di rottura
MOVE-CORRESPONDING BSIK TO BREAK.
* Create new clear
IF BREAK <> OLD_BREAK.
* header data:
IF P_TEST = SPACE.
MAX
2009 Jun 07 7:55 AM
PERFORM FILL_NO_DATA USING BBKPF 'BBKPF'.
BBKPF-STYPE = '1'.
BBKPF-TCODE = 'FB05'.
BBKPF-BLART = <document type>.
BBKPF-BUKRS = BSIK-BUKRS.
BBKPF-WAERS = BSIK-WAERS.
BBKPF-AUGLV = 'UMBUCHNG'. "Giro conto con pareggio
* BBKPF-XBLNR = <?????????>.
* BBKPF-BKTXT = <???????????>.
WRITE: P_BUDAT TO BBKPF-BUDAT,
P_BLDAT TO BBKPF-BLDAT.
TRANSFER BBKPF TO P_FILENAME.
* header data for open item selection
PERFORM FILL_NO_DATA USING BSELK 'BSELK'.
BSELK-STYPE = '2'.
BSELK-TBNAM = 'BSELK'.
BSELK-AGKON = BSIK-LIFNR.
BSELK-AGBUK = BSIK-BUKRS.
BSELK-AGKOA = 'K'.
IF BSIK-UMSKZ IS INITIAL.
BSELK-XNOPS = 'X'.
ELSE.
BSELK-AGUMS = BSIK-UMSKZ.
ENDIF.
TRANSFER BSELK TO P_FILENAME.
* item data for open item selection
PERFORM FILL_NO_DATA USING BSELP 'BSELP'.
BSELP-STYPE = '2'.
BSELP-TBNAM = 'BSELP'.
BSELP-FELDN_1 = 'ZUONR'.
BSELP-SLVON_1 = BSIK-ZUONR.
TRANSFER BSELP TO ZFAGTB01-FILENAME.
ENDIF.
ENDIF.
OLD_BREAK = BREAK.
ENDLOOP.
Max