on 02-06-2009 7:36 AM
Hi all,
Could someone tells me whether I can write program in SAPSCRIPT.
For example I would like to write a SELECT statement in SAPSCRIPT.
DATA: GV_NAME1 LIKE ADRC-NAME1.
SELECT SINGLE NAME1 INTO GV_NAME1 FROM ADRC
WHERE ADDRNUMBER = '0000000104'.
Please advice. Thanks.
Hi
No you cannot write a select statement in script. You can however use subroutines in a script.
Vishwa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use
/: PERORM form_sub IN PROGRAM zfom
/: USING &FIELD1&
/: CHANGING &FIELD2&
/: ENDFORM
now create a Program type M in SE38 with name zform
write your code
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/callingasub-routineinSAP+scripts
search SCN you will find many treads regarding subroutines in SAPSCRIPTS
Regards
Bala Krishna
Edited by: Bala Krishna on Feb 6, 2009 1:37 PM
HI,
If you want to print the address in your form it is not necessary to go with the select statement in the scripts
you have an option provided by SAP
/: ADDRESS
* &addrnumber& "----> pass the value of the address number from your program
/: ENDADDRESS
for further reference check the link:
[http://help.sap.com/saphelp_nw04/helpdata/en/d1/803238454211d189710000e8322d00/frameset.htm]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, you cannot write the select query in the script but you can do this in the print program and then in the script define the place where u want to print the address and write it as
/: address
&addrnumber&
/: endaddress
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You cannot write a program in form, Only If statements are used .You can select teh fields in driver program and you can declare that field string as text element in form.
Ex:
Work area is <w_a>
you declare in form
/: w_a
<fields>
You can get the values in driver program
Regards,
Rajani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/: DEFINE gv_name1 = 'AAAAAAAAA'.
/: PERFORM adrc_name IN PROGRAM zfrom
/: USING &ADRC-ADDRNUMBER& " this field should have relation to get value fron ADRC table
/: CHANGING &GV_NAME1&
/: ENDFORM
in ZFORM program
FORM adrc_name TABLES intable STRUCTURE itcsy
outtable STRUCTURE itcsy.
DATA: w_adrnumber like ADRC-ADDRNUMBER,
w_name1 like ADRC-NAME1.
READ TABLE intable INDEX 1.
w_adrnumber = intable-value.
SELECT SINGLE name1 INTO w_name1 FROM adrc
WHERE addrnumber = w_adrnumber.
IF sy-subrc = 0.
READ TABLE outtable INDEX 1.
outtable-value = w-name11.
MODIFY outtable INDEX 1.
ENDIF.
ENDFORM. "adrc_name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
You can not write SELECT statements in sap script , you can only write IF-ENDIF statements to only print text elements.
you have to write seperate calling program for sap script where you can use PERFORM statement to transfer data to programs and program data into SAP script without having to change your print program.
e.g code in sap script
/: PERFORM GET_DATA IN PROGRAM ZLSV_SCRPFM_RG00 (CAlling program name)
/:USING &MARA-MATNR& (material number)
/:CHANGING &G_MATNR& (TExt element)
/:ENDPERFORM
e.g code in Z program
FORM GET_DATA TABLES input_table STRUCTURE itcsy
output_table STRUCTURE itcsy.
DATA : l_matnr TYPE mara-matnr,
l_symbol TYPE C.
REFRESH output_table.
CLEAR output_table.
LOOP AT input_table.
CASE input_table-name.
WHEN 'MARA-MATNR'.
l_matnr = input_table-value.
ENDCASE.
ENDLOOP.
SELECT matnr INTO l_matnr
FROM mara
UP TO 1 ROWS
WHERE matnr = l_matnr
ENDSELECT.
IF syst-subrc EQ 0.
MOVE 'MARA-MATNR' TO output_table-name.
MOVE l_matnr TO output_table-value.
APPEND output_table.
CLEAR output_table.
ENDIF.
ENDFORM.
Here you can write your logic in Zprogram and get value of matnr from program and print this value in sap script and using &G_MATNR& command in script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can use if ...endif.
better write a program with subroutine for
GV_NAME1 LIKE ADRC-NAME1.
SELECT SINGLE NAME1 INTO GV_NAME1 FROM ADRC
WHERE ADDRNUMBER = '0000000104'.
Then in the script,make use of perform...endperform in the text editor.
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 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.