Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Writing form routine for SAPscript....

Former Member
0 Likes
1,403

Hi,

I need to write a perform in SAPscript.

Using EBELN from table ESSR I am supposed to get PACKNO and use that PACKNO field in Sapscript

/: Perform Get_Pack in program ZGET_Pack

/: using &EBELN

/: CHANGING &PACK&

Then I create program ZGET_PACK with type 'S' in se38

How do I write form endform in the 'S' type program for above perform ?

-Rajesh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,091

Hi Rajesh,

1) The driver program has two parameters of structure of ITCSY.

2) ITCSY structure will take all import and export parameters.

3) ITCSY has two fields with NAME and VALUE.

NAME is the parameter name like 'EBELN' and

VALUE is the value for the parameter you pass to routine for export parameters and is the value you get out of routine for import parameters.

4) FORM...ENDFORM is independent to program type whether it is 'S' or 'E' or '1'.

Try as follows for routine in program ZGET_PACK.

<b>FORM GET_PACK TABLES IT_INPUT STRUCTURE ITCSY

IT_OUTPUT STRUCTURE ITCSY.</b>

DATA:

V_EBELN TYPE ESSR-EBELN,

V_PACK TYPE ESSR-PACKNO.

READ TABLE IT_INPUT WITH KEY 'EBELN'.

IF SY-SUBRC = 0.

MOVE IT_INPUT-VALUE TO V_EBELN.

ENDIF.

*WRITE YOUR QUERY TO GET VALUE OF PACK INTO V_PACK.

READ TABLE IT_OUTPUT WITH KEY 'PACK'.

IF SY-SUBRC = 0.

MOVE PACK TO IT_OUTPUT-VALUE.

MODIFY IT_OUTPUT INDEX SY-TABIX.

ENDIF.

<b>ENDFORM.</b>

Thanks,

Vinay

6 REPLIES 6
Read only

Former Member
0 Likes
1,091

you dont have to create it as type 's'.

use type 'e'

Read only

0 Likes
1,091

Ok. But how do I write form-endform for it ?

Read only

0 Likes
1,091

report something.

form get_something.

endform.

No need to write a start of selection

Read only

Former Member
0 Likes
1,092

Hi Rajesh,

1) The driver program has two parameters of structure of ITCSY.

2) ITCSY structure will take all import and export parameters.

3) ITCSY has two fields with NAME and VALUE.

NAME is the parameter name like 'EBELN' and

VALUE is the value for the parameter you pass to routine for export parameters and is the value you get out of routine for import parameters.

4) FORM...ENDFORM is independent to program type whether it is 'S' or 'E' or '1'.

Try as follows for routine in program ZGET_PACK.

<b>FORM GET_PACK TABLES IT_INPUT STRUCTURE ITCSY

IT_OUTPUT STRUCTURE ITCSY.</b>

DATA:

V_EBELN TYPE ESSR-EBELN,

V_PACK TYPE ESSR-PACKNO.

READ TABLE IT_INPUT WITH KEY 'EBELN'.

IF SY-SUBRC = 0.

MOVE IT_INPUT-VALUE TO V_EBELN.

ENDIF.

*WRITE YOUR QUERY TO GET VALUE OF PACK INTO V_PACK.

READ TABLE IT_OUTPUT WITH KEY 'PACK'.

IF SY-SUBRC = 0.

MOVE PACK TO IT_OUTPUT-VALUE.

MODIFY IT_OUTPUT INDEX SY-TABIX.

ENDIF.

<b>ENDFORM.</b>

Thanks,

Vinay

Read only

Former Member
0 Likes
1,091

<b>all the paramters you pass from SCRIPT with USING command will come into ITAB.

all parameters with CHANGING command will comes into OTAB</b>

FORM  Get_Pack TABLES ITAB   STRUCTURE ITCSY
                      OTAB   STRUCTURE ITCSY.
data: v_ebeln type ekko-ebeln.

*--TO read the values from the ITAB you have to use this logic.
  READ TABLE ITAB WITH KEY NAME = 'EBELN'
         TRANSPORTING VALUE.
  IF SY-SUBRC = 0.
    CONDENSE ITAB-VALUE.
    V_EBELN = ITAB-VALUE.
  ENDIF.
*--to modify PACK value
*--write your logic to get the value into V_PACK_VALUE. 
   OTAB-VALUE = V_pack_value.
   condense OTAB-VALUE>
   MODIFY OTAB  TRANSPORTING VALUE 
             WHERE NAME = 'PACK'.
ENDFORM.

You can create the program either as Executable or subroutine pool in SE38. there will not be any difference,i guess.

Regards

Srikanth

Message was edited by: Srikanth Kidambi

Read only

Former Member
0 Likes
1,091

/: Perform Get_Pack in program ZGET_Pack

/: using &EBELN

/: CHANGING &PACK&

In the program ZGET_PACK, You can use the following form statments.

FORM GET_PACK TABLES IN_PAR STUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA: V_EBELN LIKE EKKO-EBELN,

V_PACK(10).

*--Reading EBELN value

READ TABLE IN_PAR WITH KEY ‘EBELN’.

IF SY-SUBRC = 0.

V_EBELN = IN_PAR-VALUE.

ENDIF.

***-- Put your logic to the PACK data and at the end you

***-- need to pass the value of PACK back to the subroutine.

READ TABLE OUT_PAR WITH KEY ‘PACK’.

IF SY-SUBRC = 0.

OUT_PAR-VALUE = V_PACK.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDIF.

ENDFORM.