on 08-11-2008 7:12 AM
How to populate data from internal tables to sapscript:- i am sending u sample code for reference. in the code values are coming in internal table but not getting populated in sapscript.
&----
*& Report ZTEST_SCRIPT *
*& *
&----
*& *
*& *
&----
report ztest_script .
tables: mara.
types : begin of x_itab ,
matnr type mara-matnr,
end of x_itab.
data : itab type standard table of x_itab with header line.
&----
*& Form entry
&----
text
----
-->RETCODE text
-->XSCREEN text
----
form entry using retcode like sy-subrc
xscreen like boole-boole.
itab-matnr = '123456'.
append itab.
call function 'OPEN_FORM'
exporting
device = 'PRINTER'
form = 'ZTEST_SCRIPT'.
*loop at itab.
*
*
*
*call function 'START_FORM'.
call function 'START_FORM'
exporting
ARCHIVE_INDEX =
form = 'ZTEST_SCRIPT'
LANGUAGE = ' '
STARTPAGE = ' '
PROGRAM = ' '
MAIL_APPL_OBJECT =
IMPORTING
LANGUAGE =
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
SPOOL_ERROR = 6
CODEPAGE = 7
OTHERS = 8
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*
*move-corresponding itab to mara.
read table itab index 1.
if sy-subrc = 0.
call function 'WRITE_FORM'
exporting
element = 'LABEL'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'MAIN'.
endif.
*endloop.
call function 'END_FORM'.
call function 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*call function 'CLOSE_FORM'.
endform. "entry
1) U need to populate the data in print program using select statements then u will get data in Internal table.
2) u need to display that field name in the form using the below syntax.
&ITAB-FIELD1&
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If u are passing data from dirver program to layout .. At layout what ever the variables u want to get U need to place the varable inbetween &____&..
Hope Helpfull
Raghunath.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
at form, used & and end with & for display the output like &itab-matnr&
link: [abap notes & tips|abap4beginner.blogspot.com]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
H,
Do as below.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = 'ZTEST_SCRIPT'
LANGUAGE = SY-LANGU
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
codepage = 11
OTHERS = 12
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Loop at itab .
call function 'WRITE_FORM'
exporting
element = 'LABEL'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'MAIN'.
ENDLOOP.
Call Function 'CLOSE_FORM'.
In SE71 'ZTEST_SCRIPT' in main window
add a field like &ITAB-MATNR&.
ex:-
/E LABELS
P1 &ITAB-MATNR&.
Regards
Krishna
Edited by: Bala Krishna on Aug 11, 2008 12:28 PM
Edited by: Bala Krishna on Aug 11, 2008 12:29 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
In the Main Window of SAP Script (in SE71). Add the text "&x_itab-matrn&", save the Script and Activate it again. Then check whether the ITEM No is displayed or not in the Output.
Hope it helps.
Murthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.