Application Development 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: 

Adding in Select statement for SAPscript printout

Former Member
0 Kudos

Hi everyone,

I have a new requirement where i would need to output a new field in a sapscript printout.


A summary of the requirements is as follows:
-> If EKPO-PSTYP = '3'
   -> select RSNUM
      from EKET
      where EKET-EBELN = EKPO-EBELN and
            EKET-EBELP = EKPO-EBELP
   -> select MATNR
      from RESB
      where RESB-RSNUM = EKET-RSNUM
   -> display RESB-MATNR in printout

At the moment, the sapscript is only reading from table EKPO, whereas for the new requirement to work, i'll also need to read from table EKET and RESB. Am i right to understand that sapscript cannot read SELECT statements directly from the Change Editor and i would need to do a PERFORM statement?

The question now is, where do i put this part of the logic? Any ideas?

Message was edited by: Bernard Loh

5 REPLIES 5

Simha_
Employee
Employee
0 Kudos

Hi,

Just write the logic of ur selection in the driver program same as the previous logic u r performing.

Just take the field what u want fro that select statement and pass it to the sapscript.

just simple.

Don't be confused about it..

cheers,

Simha.

Former Member
0 Kudos

Hi Simha,

Thanks for you reply.

Actually, that was my original intention, however, i was informed by my superior to avoid amending the driver program, since it is SAP standard. Therefore, it was suggested to me to do a PERFORM statement instead.

So i would like to know how to do it.

0 Kudos

Hi bernard,

You can write your perform statement in your sapscript as in normal program.

or you can refer to this link in this data is retrieved without modification in driver program

http://www.sap-img.com/ts010.htm

Regards

Sumit Bhutani

Ps reward points if helpful

Former Member
0 Kudos

Hi,

Write a PERFORM in your script.

PERFORM GET_MATNR IN PROGRAM Z_SUBROTINEPOOL

USING W_EBELN W_EBELP

CHANGING W_MATNR

ENDPERFORM.

And check the following to write the FORM in the Z program.

The structure ITCSY is used in relation with SAPScripts. You can call a Routine in any program in SAPScript.

For eg: if you have a subroutine named ADD_INCOME in a program ZSHAIL_BASIC, you can call the subroutine in SAPScript as follows:

/: PERFORM ADD_INCOME IN PROGRAM ZSHAIL_BASIC

/: USING &var1&

/: CHANGING &var2&

/: ENDPERFORM.

Here the input parameter to the subroutine is var1 and the value returned by the subroutine is var2.

In the program ZSHAIL_BASIC, you have to call the subroutine as

FORM ADD_INCOME TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.

ENDFORM.

IN_TAB is a structure of type ITCSY,which has 2 components, NAME and value.

So in the program, var1(which is sent from SAPScript) , will be stored as IN_TAB-NAME and its value will be in IN_TAB-VALUE. You can utilise the IN_TAB-VALUE and after performing the required operations, the return value should be assigned to table OUT_TAB.

This value can thus be obtained in var2 specified in SAPScript.

Also you can search for "SUBROUTINE IN SCRIPT"... "PERFORM IN SCRIPT", "ITCSY"....

Thanks and Regards,

Bharat Kumar Reddy.V

0 Kudos

Hi again, sorry for the late reply on this.

I'm still not really sure if i understood properly on this. However, this is what i have written so far:

In my SAPscript, i write:


PERFORM GET_MATNR IN PROGRAM ZLMMSS006
USING &EBELN& &EBELP&
CHANGING &W_MATNR&
ENDPERFORM

And in my Program ZLMMSS006, i write:


FORM GET_MATNR TABLE  IN_TAB STRUCTURE ITCSY
                     OUT_TAB STRUCTURE ITCSY.

DATA: RSNUM LIKE EKET-RSNUM,
      MATNR LIKE RESB-MATNR.

SELECT SINGLE RSNUM
INTO RSNUM
FROM EKET
WHERE EBELN = EBELN AND
      EBELP = EBELP.

SELECT MATNR
INTO MATNR
FROM RESB
WHERE RSNUM = RSNUM.

MATNR = OUT_TAB.

ENDFORM.

I know that what's up there is most likely wrong, but i'd like to know what do i need to change

Message was edited by: Bernard Loh