| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Document Categories:
What's New?
Contribute?Sample SpecsWhat's Hot? |
Passing table data to the layout without changing the driver programBy Joyjit Ghosh, IBM India I have seen a typical requirement from client that SAP
script layout need to be changed (additional data need to be displayed) without
modifying the driver program (mainly standard SAP program). This tip will show
us how to pass table data (multiple records at a time) to layout without
changing the driver program. Step1. Create a standard text from SO10. Create a blank standard text. This will store the table data
Step2. Create a subroutine pool and a routine in it that can
be called from SAP script. From transaction SE38 create a subroutine pool.
Now create subroutine with proper interface to fetch the data
from the table.
Step3. Within this routine write the logic to fetch the table
data and populate the standard text. ***************************************************************
* Fetch table data and upload the data in proper format to the
* standard text
***************************************************************
DATA: i_zemployee TYPE STANDARD TABLE OF zemployee INITIAL SIZE 0,
w_zemployee TYPE zemployee,
i_text TYPE STANDARD TABLE OF tline INITIAL SIZE 0,
w_header LIKE thead,
w_text TYPE tline.
CONSTANTS: c_par TYPE char2 VALUE ',,'. " Sign for tabs
* Fetch data for employee SELECT * FROM zemployee INTO TABLE i_zemployee. IF sy-subrc = 0. * Create text table
LOOP AT i_zemployee INTO w_zemployee.
* Store default paragraph format
w_text-tdformat = '*'.
* Add all the required fields separated by tab
CONCATENATE w_zemployee-empno w_zemployee-empname
INTO w_text-tdline
SEPARATED BY c_par.
* Store table data
APPEND w_text TO i_text.
ENDLOOP. check sy-subrc = 0. * Populate header info * Text object
w_header-tdobject = 'TEXT'.
* Standard text name
w_header-tdname = 'Z_TABLE_DATA'.
* Text id
w_header-tdid = 'ST'.
* Language
w_header-tdspras = 'E'.
* Populate the standard text with table data
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = w_header
insert = 'X'
savemode_direct = 'X'
TABLES
lines = i_text
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5
.
IF sy-subrc <> 0.
ENDIF. ENDIF.
Step4. Call the routine and standard text from the SAP script
layout. Note:
For the sake of simplicity this tip is shown in a custom layout that is called
from a custom report. /* Call the routine /: PERFORM FETCH_TABLE_DATA IN PROGRAM Z_SUBROUTINE_POOL /: USING &INVAR1& /: CHANGING &OUTVAR1& /: ENDPERFORM /* Now call the standard text
/: INCLUDE Z_TABLE_DATA OBJECT TEXT ID ST LANGUAGE EN
Step5. Test the SAP script form Activate the SAP script debugger
|
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||