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

SAP Script subroutine and set/assign.

Former Member
0 Likes
538

PERFORM GET_CURR IN PROGRAM ZREPORT1

USING &S_DATE&

USING &RF140-STIDA&

USING &RF140-WRSHB&

USING &SS_VAL1&

USING &SS_VAL2&

CHANGING &S_VAL1&

CHANGING &S_VAL2&

ENDPERFORM.

Every time it goes to the above perform and for the first time I get back &S_VAL1& and &S_VAL2&..

But next time I want to pass &SS_VAL1& and &SS_VAL2& with help of using.

how do I assighn/set values to

S_VAL1 to SS_VAL1 and

S_VAL2 to SS_VAL2... in SAP script.?

Any ideas?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
492

Hi,

For the first time you want SS_VAL1(2) will be blank and then from 2nd time they will be populated with S_VAL1(2) respectively???

If my understanding is correct then do like:

In Script:

DEFINE &WA_FLAG& = ' '.
PERFORM SET_FLAG IN PROGRAM ZREPORT1
CHANGING &WA_FLAG&.

if &WA_FLAG& = 'X'

  DEFINE &S_VAL1& = ' '.
  DEFINE  &S_VAL2& = ' ' .

  PERFORM GET_CURR IN PROGRAM ZREPORT1
  USING &S_DATE&
  USING &RF140-STIDA&
  USING &RF140-WRSHB&
    CHANGING &S_VAL1&
  CHANGING &S_VAL2&
  ENDPERFORM.

 DEFINE &SS_VAL1& = &S_VAL1&
  DEFINE  &SS_VAL2& = &S_VAL2&

else.

   
  PERFORM GET_CURR_NEW IN PROGRAM ZREPORT1
  USING &S_DATE&
  USING &RF140-STIDA&
  USING &RF140-WRSHB&
  USING &SS_VAL1&
  USING &SS_VAL2&
  CHANGING &S_VAL1&
  CHANGING &S_VAL2&
  ENDPERFORM.

  DEFINE &SS_VAL1& = &S_VAL1&
  DEFINE  &SS_VAL2& = &S_VAL2&


endif.

In Program

FORM SET_FLAG.

As in this we will be getting one record at a time so for the very first record set it to 'X" and then "Y"

so to know its first record or the subsequent ones declare

data:g_int type 1 globally in the program.

if g_int = 0.
    <Set WA_FLAG = 'X'>
else.
    <Set WA_FLAG = 'Y'>
endif.

ENDFORM.

PERFORM GET_CURR IN PROGRAM ZREPORT1

USING &S_DATE&

USING &RF140-STIDA&

USING &RF140-WRSHB&

USING &SS_VAL1&

USING &SS_VAL2&

CHANGING &S_VAL1&

CHANGING &S_VAL2&

ENDPERFORM.

Every time it goes to the above perform and for the first time I get back &S_VAL1& and &S_VAL2&..

But next time I want to pass &SS_VAL1& and &SS_VAL2& with help of using.

how do I assighn/set values to

S_VAL1 to SS_VAL1 and

S_VAL2 to SS_VAL2... in SAP script.?

Any ideas?

2 REPLIES 2
Read only

Former Member
0 Likes
492

Hi,

Try this..

In the subroutine create a statics variable...so that the value is retained for the next call of the subroutine...

Ex..

FORM FORM1 ...

  STATICS : V_MYVALUE TYPE CHAR10.

  IF V_MYVALUE IS INITIAL.
* First time.  
  ELSE.
    V_MYVALUE = 'TEST'.
* Subsequent times.
  ENDIF.

ENDFORM.

By doing this way...we don't have to assign the values in sapscript..

Thanks

Naren

Read only

Former Member
0 Likes
493

Hi,

For the first time you want SS_VAL1(2) will be blank and then from 2nd time they will be populated with S_VAL1(2) respectively???

If my understanding is correct then do like:

In Script:

DEFINE &WA_FLAG& = ' '.
PERFORM SET_FLAG IN PROGRAM ZREPORT1
CHANGING &WA_FLAG&.

if &WA_FLAG& = 'X'

  DEFINE &S_VAL1& = ' '.
  DEFINE  &S_VAL2& = ' ' .

  PERFORM GET_CURR IN PROGRAM ZREPORT1
  USING &S_DATE&
  USING &RF140-STIDA&
  USING &RF140-WRSHB&
    CHANGING &S_VAL1&
  CHANGING &S_VAL2&
  ENDPERFORM.

 DEFINE &SS_VAL1& = &S_VAL1&
  DEFINE  &SS_VAL2& = &S_VAL2&

else.

   
  PERFORM GET_CURR_NEW IN PROGRAM ZREPORT1
  USING &S_DATE&
  USING &RF140-STIDA&
  USING &RF140-WRSHB&
  USING &SS_VAL1&
  USING &SS_VAL2&
  CHANGING &S_VAL1&
  CHANGING &S_VAL2&
  ENDPERFORM.

  DEFINE &SS_VAL1& = &S_VAL1&
  DEFINE  &SS_VAL2& = &S_VAL2&


endif.

In Program

FORM SET_FLAG.

As in this we will be getting one record at a time so for the very first record set it to 'X" and then "Y"

so to know its first record or the subsequent ones declare

data:g_int type 1 globally in the program.

if g_int = 0.
    <Set WA_FLAG = 'X'>
else.
    <Set WA_FLAG = 'Y'>
endif.

ENDFORM.