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

Clearing document items

Former Member
0 Likes
3,597

Hi all,

I am using FM POSTING_INTERFACE_CLEARING to clear two documents. Function works fine when I clear 2 whole documents. But in some cases I need to clear just specified document line item with the other document. Is this possible using this FM? If yes, can anybody paste example or explain, how call this function and how specify document line item to clear?

Thanks a lot for reply.

9 REPLIES 9
Read only

Former Member
0 Likes
2,418

For clearing the Specific Line Item You have to fill Table T_FTPOST acoordingly with Line Item Number(P 1 for item one P2 for item 2 and so on).

See the Documentation of FM POSTING_INTERFACE_CLEARING.

And to know how to fill T_FTPOST follow Documentation of 'POSTING_INTERFACE_DOCUMENT'.

Read only

0 Likes
2,418

Thanks for helpful info. Addition question. I'm using structure BLNTAB to specify documents to clear. If I specify document items to clear in FTPOST structure as described in documentation, do I still have to use BLNTAB structure or I can do not have to care about this table anymore? Thanks.

Read only

0 Likes
2,418

Which method you are using with this BAPI?

I think BLNTAB is only for only for Call Trans .since you suppose to delete only two documets line item than just pass Document number to BLNTAB.

Read only

0 Likes
2,418

No no, maybe we don't understand each other. I have 2 documents. The first one is customer invoice, the second one is customer's down payment. So I have 2 documents. BUT, down payment document has several lines of type D (customer account). I want to clear customer invoice (having one line of type D) with one line from down payment document. So, do I have to insert the number of invoice and down payment to BLNTAB internal table? Thanks.

Read only

0 Likes
2,418

T_BLNTAB is Mandatory Field.

Read only

0 Likes
2,418

Sorry, trying to fill FTPOST table, but still does not work ... it seems like data in FTPOST table are ignored. Can anybody correct my problem or point out, where the problem is? Thanks.

  • initialize input internal tables

t_ftpost-count = 1.

t_ftpost-stype = 'K'.

t_ftpost-fnam = 'BKPF-BLDAT'.

t_ftpost-fval = l_bldat.

CONCATENATE t_ftpost-fval6(2) t_ftpost-fval4(2) t_ftpost-fval(4) INTO t_ftpost-fval.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BUDAT'.

t_ftpost-fval = sy-datum.

CONCATENATE t_ftpost-fval6(2) t_ftpost-fval4(2) t_ftpost-fval(4) INTO t_ftpost-fval.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BLART'.

t_ftpost-fval = 'ZC'.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BUKRS'.

t_ftpost-fval = r_ifblnr-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-WAERS'.

t_ftpost-fval = r_ifblnr-waers.

APPEND t_ftpost.

  • initialize documents to be cleared

t_ftpost-count = 1.

t_ftpost-stype = 'P'.

t_ftpost-fnam = 'BSEG-BUKRS'.

t_ftpost-fval = inv_bseg-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BELNR'.

t_ftpost-fval = inv_bseg-belnr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-GJAHR'.

t_ftpost-fval = inv_bseg-gjahr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BUZEI'.

t_ftpost-fval = inv_bseg-buzei.

APPEND t_ftpost.

t_ftpost-count = 2.

t_ftpost-stype = 'P'.

t_ftpost-fnam = 'BSEG-BUKRS'.

t_ftpost-fval = adv_bseg-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BELNR'.

t_ftpost-fval = adv_bseg-belnr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-GJAHR'.

t_ftpost-fval = adv_bseg-gjahr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BUZEI'.

t_ftpost-fval = adv_bseg-buzei.

APPEND t_ftpost.

t_ftclear-agkoa = 'D'.

t_ftclear-agkon = r_belnr-kunnr.

t_ftclear-agbuk = r_ifblnr-bukrs.

t_ftclear-xnops = 'X'.

t_ftclear-agums = 'A'.

t_ftclear-selvon = r_bsad-augbl.

t_ftclear-selfd = 'BELNR'.

APPEND t_ftclear.

CLEAR t_ftclear-agums.

t_ftclear-selvon = document_number.

t_ftclear-selfd = 'BELNR'.

APPEND t_ftclear.

CLEAR t_ftclear.

  • initialize table of document numbers to be cleared

  • t_blntab-belnr = r_bsad-augbl.

  • t_blntab-bukrs = r_bsad-bukrs.

  • t_blntab-gjahr = r_bsad-auggj.

  • APPEND t_blntab.

  • t_blntab-belnr = document_number.

  • APPEND t_blntab.

  • clear documents

CALL FUNCTION 'POSTING_INTERFACE_START'

EXPORTING I_CLIENT = sy-mandt

I_FUNCTION = 'C' "LIKE RFIPI-FUNCT

I_GROUP = SPACE

  • I_HOLDDATE = SPACE

  • I_KEEP = SPACE

I_MODE = 'A' "'N'

  • I_UPDATE = 'S'

I_USER = sy-uname

I_XBDCC = SPACE.

CALL FUNCTION 'POSTING_INTERFACE_CLEARING'

EXPORTING i_auglv = 'AUSGZAHL'

i_tcode = 'FB05'

IMPORTING e_msgid = i_msgid

e_msgno = i_msgno

e_msgty = i_msgty

e_msgv1 = i_msgv1

e_msgv2 = i_msgv2

e_msgv3 = i_msgv3

e_msgv4 = i_msgv4

e_subrc = i_subrc

TABLES t_blntab = t_blntab

t_ftclear = t_ftclear

t_ftpost = t_ftpost

t_fttax = t_fttax

EXCEPTIONS others = 1.

Read only

0 Likes
2,418

Problem solved! No need to insert FTPOST records! When inserting FTCLEAR records, for t_ftclear-selfd = 'BELNR' record should be document number specified in BELNR-GJAHR-BUZEI format, like CONCATENATE inv_bseg-belnr inv_bseg-gjahr inv_bseg-buzei INTO t_ftclear-selvon. Then transactions clears only specified items.

Read only

0 Likes
2,418

hI,

I am also using the same FM for clearing open AP documents so, could you please give me the sample code how fill the FM details....Thanks in advance.

Regards,

Arun

Read only

0 Likes
2,418

Here is an example code, hoping it will be useful ...

  • select the first line item to be cleared

SELECT SINGLE * FROM BSEG INTO inv_bseg WHERE BUKRS = header-company_code AND BELNR = document_number AND GJAHR = document_year AND KOART = 'D'.

CHECK sy-subrc = 0.

  • select the second line item to be cleared

SELECT SINGLE * FROM BSEG INTO adv_bseg WHERE BUKRS = adv_bse_clr-bukrs_clr AND BELNR = adv_bse_clr-belnr_clr AND GJAHR = adv_bse_clr-gjahr_clr AND UMSKZ = 'A'.

CHECK sy-subrc = 0.

  • initialize input internal tables

t_ftpost-count = 1.

t_ftpost-stype = 'K'.

t_ftpost-fnam = 'BKPF-BLDAT'.

t_ftpost-fval = l_bldat.

CONCATENATE t_ftpost-fval6(2) t_ftpost-fval4(2) t_ftpost-fval(4) INTO t_ftpost-fval.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BUDAT'.

t_ftpost-fval = sy-datum.

CONCATENATE t_ftpost-fval6(2) t_ftpost-fval4(2) t_ftpost-fval(4) INTO t_ftpost-fval.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BLART'.

t_ftpost-fval = 'ZC'.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-BUKRS'.

t_ftpost-fval = r_ifblnr-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-XBLNR'.

t_ftpost-fval = document_number.

APPEND t_ftpost.

t_ftpost-fnam = 'BKPF-WAERS'.

t_ftpost-fval = r_ifblnr-waers.

APPEND t_ftpost.

  • initialize documents to be cleared

t_ftpost-count = 1.

t_ftpost-stype = 'P'.

t_ftpost-fnam = 'BSEG-BUKRS'.

t_ftpost-fval = inv_bseg-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BELNR'.

t_ftpost-fval = inv_bseg-belnr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-GJAHR'.

t_ftpost-fval = inv_bseg-gjahr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BUZEI'.

t_ftpost-fval = inv_bseg-buzei.

APPEND t_ftpost.

t_ftpost-count = 2.

t_ftpost-stype = 'P'.

t_ftpost-fnam = 'BSEG-BUKRS'.

t_ftpost-fval = adv_bseg-bukrs.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BELNR'.

t_ftpost-fval = adv_bseg-belnr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-GJAHR'.

t_ftpost-fval = adv_bseg-gjahr.

APPEND t_ftpost.

t_ftpost-fnam = 'BSEG-BUZEI'.

t_ftpost-fval = adv_bseg-buzei.

APPEND t_ftpost.

t_ftclear-agkoa = 'D'.

t_ftclear-agkon = r_belnr-kunnr.

t_ftclear-agbuk = r_ifblnr-bukrs.

t_ftclear-xnops = 'X'.

t_ftclear-agums = 'A'.

CONCATENATE adv_bseg-belnr adv_bseg-gjahr adv_bseg-buzei INTO t_ftclear-selvon.

t_ftclear-selfd = 'BELNR'.

APPEND t_ftclear.

CLEAR t_ftclear-agums.

CONCATENATE inv_bseg-belnr inv_bseg-gjahr inv_bseg-buzei INTO t_ftclear-selvon.

t_ftclear-selfd = 'BELNR'.

APPEND t_ftclear.

CLEAR t_ftclear.

  • clear documents

CALL FUNCTION 'POSTING_INTERFACE_START'

EXPORTING I_CLIENT = sy-mandt

I_FUNCTION = 'C' "LIKE RFIPI-FUNCT

I_GROUP = SPACE

  • I_HOLDDATE = SPACE

  • I_KEEP = SPACE

I_MODE = 'N'

  • I_UPDATE = 'S'

I_USER = sy-uname

I_XBDCC = SPACE.

CALL FUNCTION 'POSTING_INTERFACE_CLEARING'

EXPORTING i_auglv = 'AUSGZAHL'

i_tcode = 'FB05'

IMPORTING e_msgid = i_msgid

e_msgno = i_msgno

e_msgty = i_msgty

e_msgv1 = i_msgv1

e_msgv2 = i_msgv2

e_msgv3 = i_msgv3

e_msgv4 = i_msgv4

e_subrc = i_subrc

TABLES t_blntab = t_blntab

t_ftclear = t_ftclear

t_ftpost = t_ftpost

t_fttax = t_fttax

EXCEPTIONS others = 1.

IF sy-subrc <> 0.

returnTab-type = i_msgty.

returnTab-id = i_msgid.

returnTab-number = i_msgno.

returnTab-message_v1 = i_msgv1.

returnTab-message_v2 = i_msgv2.

returnTab-message_v3 = i_msgv3.

returnTab-message_v4 = i_msgv4.

INSERT returnTab INDEX 1.

ENDIF.

CALL FUNCTION 'POSTING_INTERFACE_END'

EXPORTING I_BDCIMMED = SPACE.