Skip to Content
author's profile photo Former Member
Former Member

COPA Fields using the FM PRELIMINARY_POSTING_FB01

Hi everyone,

I am using the Function modules PRELIMINARY_POSTING_FB01 to park the GL invoice documents. I am not able to populate the COPA fields of the document. How do we pass copa fields to the FM PRELIMINARY_POSTING_FB01?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2011 at 09:11 AM

    Hi,

    First populate PAOBJNR, PASUBNR from function module COPA_PRELIMINARY_SEGMENT and pass these to PRELIMINARY_POSTING_FB01 - TBSEG-PAOBJNR AND TBSEG-PASUBNR.

    Populating PAOBJNR:

    FORM get_paobjnr TABLES pt_tbkpf TYPE gty_tbkpf

    pt_tbseg TYPE gty_tbseg.

    DATA: lv_tabix TYPE sy-tabix,

    lv_kokrs TYPE kokrs,

    wa_cobl TYPE cobl,

    wa_cobl1 TYPE cobl.

    READ TABLE pt_tbkpf INTO wa_tbkpf INDEX 1.

    READ TABLE gt_bukrs INTO wa_bukrs WITH KEY bukrs = wa_tbkpf-bukrs BINARY SEARCH.

    IF sy-subrc = 0.

    READ TABLE it_tka01 INTO wa_tka01 WITH KEY ktopl = wa_bukrs-ktopl BINARY SEARCH.

    IF sy-subrc = 0.

    lv_kokrs = wa_tka01-kokrs.

    ENDIF.

    ENDIF.

    LOOP AT it_bseg INTO wa_bseg WHERE ( copa_kunnr IS NOT INITIAL OR

    copa_matnr IS NOT INITIAL OR

    copa_werks IS NOT INITIAL OR

    copa_vkorg IS NOT INITIAL OR

    copa_vtweg IS NOT INITIAL OR

    copa_spart IS NOT INITIAL OR

    copa_pspnr IS NOT INITIAL OR

    copa_prctr IS NOT INITIAL ) AND

    copa_valid = c_x.

    lv_tabix = sy-tabix.

    wa_cobl-glvor = 'RFBU'.

    wa_cobl-vorgn = 'RFBU'.

    wa_cobl-process = 'BELEGPOS'.

    wa_cobl-event = 'PRUEFEN'.

    wa_cobl-budat = wa_tbkpf-budat.

    wa_cobl-bldat = wa_tbkpf-bldat.

    wa_cobl-bukrs = wa_tbkpf-bukrs.

    wa_cobl-hkont = wa_bseg-hkont.

    wa_cobl-koart = c_s.

    wa_cobl-kokrs = lv_kokrs.

    wa_cobl-gjahr = wa_tbkpf-gjahr.

    wa_cobl-blart = wa_tbkpf-blart.

    wa_cobl-bschl = wa_bseg-bschl.

    wa_cobl-waers = wa_tbkpf-waers.

    wa_cobl-wrbtr = wa_bseg-wrbtr.

    wa_cobl-kunnr = wa_bseg-copa_kunnr.

    wa_cobl-vkorg = wa_bseg-copa_vkorg.

    wa_cobl-vtweg = wa_bseg-copa_vtweg.

    wa_cobl-spart = wa_bseg-copa_spart.

    wa_cobl-matnr = wa_bseg-copa_matnr.

    wa_cobl-werks = wa_bseg-copa_werks.

    CALL FUNCTION 'COPA_PROFITABILITY_SEGMENT'

    EXPORTING

    dialog = space

    i_cobl = wa_cobl

    i_update = c_x

    IMPORTING

    e_cobl = wa_cobl1

    EXCEPTIONS

    abnormal_leave = 1

    btrans_not_relevant = 2

    error_copa = 3

    OTHERS = 4.

    IF sy-subrc = 0.

    READ TABLE pt_tbseg INTO wa_tbseg INDEX lv_tabix.

    IF sy-subrc = 0.

    wa_tbseg-paobjnr = wa_cobl1-paobjnr.

    wa_tbseg-pasubnr = wa_cobl1-pasubnr.

    MODIFY pt_tbseg FROM wa_tbseg INDEX sy-tabix TRANSPORTING paobjnr pasubnr.

    ENDIF.

    ENDIF.

    ENDLOOP.

    ENDFORM. " GET_PAOBJNR

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.