Skip to Content

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

Calculate open quantity for pending contracts in VA45

Hi Experts,

I wanted to get the open quantity for contracts. In VA45, i got the following code written:

LOOP AT lvbmtv ASSIGNING <fs_lvbmtv>.

         CLEAR:lv_menge.

         LOOP AT lit_vbfa INTO lwa_vbfa WHERE vbelv = <fs_lvbmtv>-vbeln.

           READ TABLE git_vbap_n INTO lwa_vbap_n WITH KEY vbeln = lwa_vbfa-vbeln.

           IF sy-subrc = 0.

             lv_menge = lv_menge + lwa_vbap_n-kwmeng.

           ENDIF.

         ENDLOOP.

         CLEAR:lv_menge_n.

         READ TABLE git_vbap INTO lwa_vbap WITH KEY vbeln = <fs_lvbmtv>-vbeln.

         IF sy-subrc = 0.

           lv_menge_n lwa_vbap-zmeng - lv_menge.

         ENDIF.

         <fs_lvbmtv>-zmeng = lv_menge_n.

       ENDLOOP.

       MOVE lv_menge_n TO lvbmtv-zmeng.


Now, this works fine if a contract has been referenced by sales orders with single line items. But in case of multiple line items, the code only calculates the open quantity for the first line and not for the others. My ABAP consultant has been unable to get the line items included.

Could you please help me out.


Thanks

Pranay

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