Skip to Content
0
Former Member
Nov 20, 2008 at 09:06 AM

Calling subroutine from SAP script

26 Views

I am using the below code within my SAP script form that prints GR/GI Slips but its not working. And the only way I can issue the output is from MB02 whcih doesn't seem to allow to call the debuger, so I'm at a lost as to what to do.

Code in SAP script

/:	 	PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS                                                                                
USING &MSEG-MATNR&
/:	 	                                                USING &MSEG-LGNUM&
/:	 	                                                CHANGING &MABDR-LGPBE&
/:	 	ENDPERFORM

CODE from my subroutine program:

FORM get_bins TABLES input_table STRUCTURE itcsy
                     output_table STRUCTURE itcsy.

  DATA: lc_matnr    TYPE matnr,
        lc_lgnum    TYPE lgnum,
        lc_lgpla    TYPE lgpla,
        lc_index    TYPE sy-tabix.

* Material no
  READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
  MOVE input_table-value TO lc_matnr.

* Warehouse number
  READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
  MOVE input_table-value TO lc_lgnum.


* Get BIN
  SELECT SINGLE lgpla INTO lc_lgpla
         FROM mlgt
         WHERE matnr = lc_matnr
         AND   lgnum = 'CPT'  "lc_lgnum
         AND   lgtyp = '001'.
  IF sy-subrc = 0.
    READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
    lc_index = sy-tabix.
    MOVE lc_lgpla TO output_table-value.
    MODIFY output_table INDEX lc_index.
  ENDIF.