cancel
Showing results for 
Search instead for 
Did you mean: 

Add Code in a SapScript Form

former_member257859
Participant
0 Kudos

Hello

Is it possible to add the following code to a SAPscript Form or does it have to be done in the driver program?

SELECT SINGLE *

INTO wa_adrc

FROM adrc

WHERE addrnumber = REGUH-ZADNR.

I know in Smartforms you can use Program Lines to insert code within the form, just wanted to know if can do same thing in SAPscript ?

Thanks

Gary

Accepted Solutions (1)

Accepted Solutions (1)

former_member257859
Participant
0 Kudos

Thanks Ernesto

I did the following like you suggeted and it works.

FORM getaddr TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.

break spgmr18.

READ TABLE out_par WITH KEY 'REGUH-ZNME1'.

CHECK sy-subrc = 0.

out_par-value = 'GARY'.

MODIFY out_par INDEX sy-tabix.

ENDFORM. "getaddr

But not reuturning value 'GARY' (&REGUH-ZNME1&) to SAPscript:

PERFORM GETADDR IN PROGRAM ZCHECK_CODE

USING &REGUH-ZADNR&

CHANGING &REGUH-ZNME1&

ENDPERFORM

ADDRESS PARAGRAPH ZD

TITLE &REGUH-ZANRE&

NAME &REGUH-ZNME1&, &REGUH-ZNME2&, &REGUH-ZNME3&, &REGUH-ZNME4&

STREET &REGUH-ZSTRA&

POBOX &REGUH-ZPFAC& CODE &REGUH-ZPST2&

POSTCODE &REGUH-ZPSTL&

REGION &REGUH-ZREGI&

CITY &REGUH-ZORT1&, &REGUH-ZORT2&

COUNTRY &REGUH-ZLAND&

FROMCOUNTRY &T001-LAND1&

ENDADDRESS

Former Member
0 Kudos

Hi Gary,

You are using REGUH structure and I am not sure if you can change the values on this structre (I guess you can). Try using other variables like this:

/: DEFINE &MY_VAR&

/: PERFORM GETADDR IN PROGRAM ZCHECK_CODE

/: USING &REGUH-ZADNR&

/: CHANGING &MY_VAR&

/: ENDPERFORM

And your code:


FORM getaddr TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.
break spgmr18.
READ TABLE out_par WITH KEY 'MY_VAR'.
CHECK sy-subrc = 0.
out_par-value = 'GARY'.
MODIFY out_par INDEX sy-tabix.
ENDFORM. "getaddr

Ernesto

Answers (3)

Answers (3)

former_member257859
Participant
0 Kudos

Thanks for all the posts greatly appreciated. I created the following code in my SAPscript :

PERFORM GETADDR IN PROGRAM ZCHECK_CODE

USING &REGUH-ZADNR&

CHANGING &REGUH-ZNME1&

ENDPERFORM

I am having some issues on getting the code to work. Getting the following error:

Program "ZCHECK_CODE" is type I and therefore cannot be generated.

ZCHECK_CODE is an Include Program, code is below:

&----


*& Include ZCHECK_CODE

&----


FORM getaddr USING zadnr

CHANGING znme1.

znme1 = 'Test for Gary'.

ENDFORM. "getaddr

Former Member
0 Kudos

Hi,

The program type should be Subroutine Pool or Executable one.

Regards,

Ernesto.

Former Member
0 Kudos

Gary, please follow this piece of code:


FORM getaddr TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy. 

READ TABLE out_par WITH KEY 'REGUH-ZNME1'. 
CHECK sy-subrc = 0. 
  
out_par-value = 'GARY'. 

modify out_par index sy-tabix.

Former Member
0 Kudos

Hi,

Create a ZInude program e.g zxxxx

then inside of that program create a sub routen

e.g

form select using var1 type ITCSY changing car2 type structure ITCSY.

your select querey

and pass the result in changing variable

endform.

use following statement in SAP script

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: CHANGING &INVAR2&

/: ENDPERFORM

Thanks & Regards,

Srini.

Former Member
0 Kudos

Hi Gary,

You can add code into an include with the line:

/: DEFINE &FIELD1&

/: PERFORM 'FORM' IN PROGRAM 'ZYYYYYY'

/: USING &REGUH-ZADNR&

/: CHANGING &FIELD1&

/: ENDPERFORM

Regards,

Ernesto.

Edited by: Ernesto Caballero on Aug 4, 2011 3:09 PM