Skip to Content

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

Subroutine call from SAP Script

Hi,

I need to calculate required/outstanding qty. hence am passing existing values of reservation#/item# and issued qty.

both req/out qty are returned blank by the code. please help.

Following is my code segment for a external routine call from SAP Script.

/: PERFORM P_GET_QTY IN PROGRAM ZTEST

/: USING &MSEG-RSNUM&

/: USING &MSEG-RSPOS&

/: CHANGING &REQ_QTY&

/: CHANGING &MSEG-MENGE&

/: CHANGING &OUT_QTY&

/: ENDPERFORM

REPORT ztest .

TABLES resb.

DATA: wa_resb TYPE resb,

req_qty TYPE resb-bdmng,

isd_qty TYPE mseg-menge,

out_qty TYPE resb-bdmng.

FORM p_get_qty TABLES input STRUCTURE itcsy

output STRUCTURE itcsy.

DATA: avlbl TYPE resb-bdmng.

READ TABLE input WITH KEY 'MSEG-RSNUM'.

CHECK sy-subrc = 0.

wa_resb-rsnum = input-value.

READ TABLE input WITH KEY 'MSEG-RSPOS'.

CHECK sy-subrc = 0.

wa_resb-rspos = input-value.

READ TABLE input WITH KEY 'REQ_QTY'.

CHECK sy-subrc = 0.

req_qty = input-value.

READ TABLE input WITH KEY 'MSEG-MENGE'.

CHECK sy-subrc = 0.

isd_qty = input-value.

SELECT SINGLE * INTO wa_resb

FROM resb

WHERE rsnum = wa_resb-rsnum

AND rspos = wa_resb-rspos.

CHECK sy-subrc = 0.

avlbl = wa_resb-bdmng - wa_resb-enmng.

req_qty = avlbl - out_qty.

out_qty = req_qty - isd_qty.

output-name = 'REQ_QTY'.

output-value = req_qty.

  • MODIFY output TRANSPORTING name value WHERE name = 'REQ_QTY'.

APPEND output.

output-name = 'OUT_QTY'.

output-value = out_qty.

  • MODIFY output TRANSPORTING name value WHERE name = 'OUT_QTY'.

APPEND output.

ENDFORM.

Thanks,

Ram.

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