cancel
Showing results for 
Search instead for 
Did you mean: 

Creating new collective PR for multiple new components if previous PR is released completly

0 Kudos

Hey guys,

I'm looking for a solution for the following Problem:

We plan to switch from a position release of purchase requisition to a complete release (header release), because we want to use the total value of a PR to determinate which release strategy is used. E.g. if the total value of 500 is undercutted, no release of the PR is needed.

When creating a PR from a workorder component, a collective PR is created for all non-stock components. So we use BADI IW01_PREQ_BADI to determine, if there is any unreleased PR to the workorder. If atleast one exist, then we add all new components no this PR. But if there are only released PR, a new PR should be created. So we select all PRs to this workorder and check if any unreleased PR exist.

  METHOD if_ex_iwo1_preq_badi~decision_coll_preq.

    TYPES: BEGIN OF ty_banf,
             banfn TYPE banfn,
             frgkz TYPE eban-frgkz,
           END OF ty_banf.

    DATA: gt_banf TYPE TABLE OF ty_banf,
          gs_eban TYPE eban.

    IF c_tmp_banfn IS NOT INITIAL.

      SELECT ebkn~banfn
             eban~frgkz
        FROM ebkn
        INNER JOIN eban ON eban~banfn = ebkn~banfn
        INTO CORRESPONDING FIELDS OF TABLE gt_banf
        WHERE ebkn~aufnr = caufvd_imp-aufnr
          AND eban~estkz = 'F'
        ORDER BY frgkz DESCENDING.


      IF sy-subrc = 0.

        READ TABLE gt_banf ASSIGNING FIELD-SYMBOL(<fs_banf>)
        INDEX 1.

        IF <fs_banf>-frgkz <> '1'.
          c_tmp_banfn = <fs_banf>-banfn.
        ELSE.
          CLEAR c_tmp_banfn.
        ENDIF.

      ENDIF.

    ENDIF.

  ENDMETHOD.

This works fine , if a user only adds 1 new non-stock component in one session. But if a user adds multiple components at a time, the BADI will run for every component resulting in crealting multiple PRs with only 1 item. So we are looking for a solution to collect multiple new components which are added in one session in only one PR.

Unfortunately this BadI IWO01_PREQ_BADI helps only partialy in this problem. Is there any UserExit or BadI where we can check, for components which to this point got no PR-number, and add the next free number and set the positionnumbers accordingly?

Sincerely

Dennis

View Entire Topic
peter_atkin
Active Contributor
0 Kudos

Dennis,

You might be able to look into the ABAP memory and find the settings for any newly created PRs in the current session and read the settings. These settings could then be used to affect subsequent PRs crated in the order.

For example:

  • PR1 determines that a new PR is required and sets the relevant flag
  • PR2 determines that PR1 exists and needs to be linked (not sure how this would be done)
  • PR3 does the same as PR2

.

PeteA

0 Kudos

Dear Peter,

thank you for your reply. Your thought process is exactly what we need. Because we can't insert a temporary PR number in parameter "c_tmp_banfn" I searched for some BadI's/UserExit's which are called in the save routine. I've found BadI WOKORDER_UPDATE with Methods BEFORE_UPDATE and IN_UPDATE. Unfortunately non of those IT_COMPONENTS tables given provide information about PR because both fields BANFN and BNFPO are empty. So I may need to dig deeper to the point where the actual PR is created and use an enhancement-point or modify.

You don't maybe by chance if there is any enhancement point right before the creation of the PR?

Sincerely

Dennis

peter_atkin
Active Contributor
0 Kudos

Sorry Dennis - I don't know, and unfortunately I don't have the time to dig deeper either.

But please let us know if you manage to sort it out.