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

Available Data in printprograms

Former Member
0 Likes
703

Hello,

I have a ABAP print programm. In this program the sapscript-form ist capable of reading the data of the table SADR (Addressdata). But this table is not defined in the print program. Can I also read data which is not directly declared in the printprogram, for example from the calling program? How can I identify the data, that I can read when it is not defind in the printprogramm? Thanks.

Regards, Lars.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
672

How can I identify the data, that I can read when it is not defind in the printprogramm?

SAPSCRIPT will not show an error ( while activating ) even if the data used in it is not in Print Program. However you may not see the data when you print. While printing also you may not encounter an error ( such as data not defined ).

You can check for data being used but not defined in main program with FORM -> CHECK TEXT ( Male sure Symbol Chk is turned on here ). Any undefined data you will see an error here.

Apart for program data , system symbols , sapscript symbols can be used directly in sapscript . No need to define them.

Cheers

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
672

The values in which you want to print in the SAPScript form must be global variables of the print program.

You can, however, use a PERFORM statement inside the SAPscript.

You define fields in a SAPSCRipt using DEFINE. Then you call a FORM in Program. The the form you get the data and pass it back thru the FORM interface.

Regards,

Rich Heilman

Read only

0 Likes
672

Here is an example of a sapscript doing a perform. It is sending the sales order number and getting the telephone number of the partner back.

Sapscript code.


DEFINE &TEL_NUMBER& = &SPACE&
PERFORM 'TELEPHONE' IN PROGRAM 'ZCUSTOM_PROGRAM'       
USING &VBELN&.                                 
CHANGING &TEL_NUMBER&                             
ENDPERFORM

ABAP Program code.

FORM TELEPHONE     TABLES CO_SYM_USING   STRUCTURE ITCSY
                          CO_SET_SYMBOLS STRUCTURE ITCSY.

  CLEAR: WK_VBELN,
         TEL_NUMBER.

  READ TABLE CO_SYM_USING WITH KEY NAME = 'VBELN'.
  CHECK SY-SUBRC EQ 0.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
            INPUT  = CO_SYM_USING-VALUE
       IMPORTING
            OUTPUT = WK_VBELN
       EXCEPTIONS
            OTHERS = 1.
  CHECK SY-SUBRC EQ 0.


*Sales Document: Partner
data: xvbpa
  SELECT SINGLE FROM VBPA
         INTO xvbpa
               WHERE VBELN = WK_VBELN
                 AND POSNR = '000000'
                 AND PARVW = 'WE'.
*Addresses (central address admin.)
  SELECT SINGLE TEL_NUMBER  FROM ADRC
         INTO (TEL_NUMBER)
         WHERE ADDRNUMBER = xvbpa-adrnr. 



*  transfer variable &TEL_NUMBER&
  READ TABLE CO_SET_SYMBOLS INDEX 1.
  CO_SET_SYMBOLS-VALUE = TEL_NUMBER.
  MODIFY CO_SET_SYMBOLS INDEX 1.

ENDFORM. "TELEPHONE

Regards,

Rich Heilman

Read only

Former Member
0 Likes
672

Yes lars, you can do it calling a program from your SAPScript. Here is an example:

SapScript

/:DEFINE &CUST& = '00000021'.

/:PERFORM GET_NAME IN PROGRAM ZTEST

/: USING &CUST&

/: CHANGING &NAME&

/:ENDPERFORM.

REPORT ZTEST

TABLES scustom.

FORM get_name tables in_tab structure itcsy out_tab structure itcsy.

read table in_tab index 1.

select single * from scustom

where id = in_tab-value.

if sy-subrc = 0.

read table out_tab index 1.

move scustom-name to out_tab-value.

modify out_tab index sy-tabix.

else.

read table out_tab index 1.

move 'No name' to out_tab-value.

modify out_tab index sy-tabix.

endif.

.............

But there should be a field in your print program which can be used to fetch the data from a different table which is not defined in your print program.

Hope this is helpful.

Read only

Former Member
0 Likes
673

How can I identify the data, that I can read when it is not defind in the printprogramm?

SAPSCRIPT will not show an error ( while activating ) even if the data used in it is not in Print Program. However you may not see the data when you print. While printing also you may not encounter an error ( such as data not defined ).

You can check for data being used but not defined in main program with FORM -> CHECK TEXT ( Male sure Symbol Chk is turned on here ). Any undefined data you will see an error here.

Apart for program data , system symbols , sapscript symbols can be used directly in sapscript . No need to define them.

Cheers