Perform statement in SAP scripts
Hi experts,
My requirement is that I don't want to display line items for particular customer with a particular item category, For this purpose I was asked to create a Z table with fields customer number(KUNNR) and Item category(PSTYV) and I have to make changes only in layout but not in driver program. So how do i do it? How to write preform statement in form layout which satisfies my requirement. And also in this perform statement I have to check if that customer and item category exists in that Z table. If so then I should not display the line item in the output else the line item should be displayed.
Thanks in Adv.
Vasu
Hi,
write this in script (Ex:Main Window)
/: PERFORM GET_COMM_CODE_DESC IN PROGRAM ZVPPACKL
/: USING &VBDPL-MATNR&
/: USING &VBDPL-WERKS&
/: USING &VBDPL-STAWN&
/: USING &VBDKL-ALAND&
/: CHANGING &STAWN&
/: CHANGING &TEXT1&
/* Begin of Insert -- PRAVIKAN -- DV2K933249 -- PR091808
/: CHANGING &W_COMMODITY_EU&
/: CHANGING &W_COMMODITY_DESC_EU&
/* End of Insert -- PRAVIKAN -- DV2K933249 -- PR091808
/: ENDPERFORM
Driver program (ZVPPACKL)
FORM get_comm_code_desc TABLES intab STRUCTURE itcsy
outtab STRUCTURE itcsy.
DATA: stawn LIKE t604t-stawn,
matnr LIKE marc-matnr, "CL060501
werks LIKE marc-werks, "CL060501
land1 LIKE t604t-land1,
text1 LIKE t604t-text1,
w_commodity_eu TYPE stawn, "PR092908
w_commodity_desc_eu TYPE bezei40. "PR092908
READ TABLE intab WITH KEY name = 'VBDPL-MATNR'. "CL060501
matnr = intab-value. "CL060501
READ TABLE intab WITH KEY name = 'VBDPL-WERKS'. "CL060501
werks = intab-value. "CL060501
land1 = intab-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = matnr
IMPORTING
output = matnr.
CLEAR: stawn,
text1.
SELECT SINGLE stawn
INTO stawn
FROM marc
WHERE matnr = matnr
AND werks = '3101'.
IF NOT stawn IS INITIAL.
SELECT SINGLE text1
INTO text1
FROM t604t
WHERE spras = 'EN'
AND land1 = 'US'
AND stawn = stawn.
ENDIF.
CLEAR: w_commodity_eu,
w_commodity_desc_eu.
SELECT SINGLE stawn
INTO w_commodity_eu
FROM marc
WHERE matnr = matnr
AND werks = '0010'.
IF NOT w_commodity_eu IS INITIAL.
SELECT SINGLE text1
INTO w_commodity_desc_eu
FROM t604t
WHERE spras = 'EN'
AND land1 = 'GB'
AND stawn = w_commodity_eu.
ENDIF.
READ TABLE outtab WITH KEY name = 'STAWN'. "CL060501
outtab-value = stawn. "CL060501
MODIFY outtab INDEX sy-tabix.
READ TABLE outtab WITH KEY name = 'TEXT1'.
outtab-value = text1.
MODIFY outtab INDEX sy-tabix.
READ TABLE outtab WITH KEY name = 'W_COMMODITY_EU'.
IF sy-subrc EQ 0.
outtab-value = w_commodity_eu.
MODIFY outtab INDEX sy-tabix.
ENDIF.
READ TABLE outtab WITH KEY name = 'W_COMMODITY_DESC_EU'.
IF sy-subrc EQ 0.
outtab-value = w_commodity_desc_eu.
MODIFY outtab INDEX sy-tabix.
ENDIF.
ENDFORM. "GET_COMM_CODE_DESC
Regards
Krishna
Similar Messages
-
How to use perform statements in sap scripts
how to use perform statements in sap scripts . and pls send me one progam for this
thnaks
rajaHi Raja,
<b>PERFORM</b> key work is used to include subroutine in sapscript form...
But the processing is lttle bit different form the one we use in ABAP.
Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
Check out the example below to see how this is used..
<b>Definition in the SAPscript form:</b>
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
<b>Coding of the calling ABAP program:</b>
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Hope this is clear to understand...
Enjoy SAP.
Pankaj Singh. -
Hi All,
I have written the below If statement in SAP scripts but when i execute the same the controll doent check the second line entries. If firtst line doesnot satisfy it goes to the else part. Kindly suggest what is wrong in this..
/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
/: &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
/: &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
/: &T156T-BWART& = '343' OR &T156T-BWART& = '344'.
/: ELSE
/: ENDIF.Hi neha,
Try to use the '/E' fo rnext line
/E->Extended line
Here is a code:
/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
/E &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
/E &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
/E &T156T-BWART& = '343' OR &T156T-BWART& = '344'.
/: ELSE
/: ENDIF.
Hope this helps you.
Regards,
Rajani -
Use of IF statement in SAP Scripts
Can u tell me how to use IF statement in SAP Scripts.
The problem is
if &sy-tabix& eq '1'
total
else
total1.
endif.
this sy-tabix is not workingi think sy-tabix will not work here....
do like this..
data : vtabix type i.
loop at itab.
vtabix = sy-tabix.
write_form...for the text element..
endloop.
in form layout
/: if &vtabix(c)& eq 1
/:endif
regards
shiba dutta -
How to debugg particular statement in sap script
hi friends,
i want to know How to debugg particular statement in sap script.
plz reply.
thanks in advance,
regards
bhaskarhi
execute rstxdbug to activate script debugger...once the driver program reaches open_form, a popup box will come where u can mention the name of a command, call functinon, text element, etc to place a break point...once it gets into the debugging mode, double click on any line to set a break point, after that pressing f8 will get you to that line
if helpful, reward
Sathish. R -
Customer Statement using SAP Script and Standard print program RFKORD10
Using sap script and standard print program RFKORD10 I need to create a customer statement where the main window will be as follows
Invoice # InvoiceDate CustomerPO Debit Amt Credit Amt Total
6 7 8 9 10 11
6 7 8 9 10 11
Totals 12 13 14
Where company code BKORM-KUKRS
Invoice BSID-BELNR
Invoice date BSID-BLDAT
Customer PO VBKD-BSTKD
For each document number selected there will be one to many records in VBRP. For each invoice item in VBRP:
u2022 Select BSTKD from VBKD where
o VBELN = VBRP-VGBEL and
o POSNR = VBRP-VGPOS
u2022 If no hits then select BSTKD from VBKD where
o VBELN = VBRP-VGBEL
If there is more than one PO per invoice then list them in the Customer PO field without repeating the other fields.PO shouldnu2019t come more than once per invoice.
Debit Amt if BSEG-SHKZG = S then WRBTR ELSE 0
Credit Amt if BSEG-SHKZG = H then WRBTR ELSE 0
Total Debit Amt u2013 Credit Amt
Totals Subtotals
It will be of great help if some one can help me with the script and the alterations required in standard print program RFKORD10
Points will b rewarded for sure.
Thanks.Hi Suganya,
The custom form is getting displayed properly. But the requirement is to have it as an editable PDF. So the functional team is working on configuring the settings of PDF forms with customers email address.
But for right now, i customized the standard form F140_ACC_STAT_01 and standard print program RFKORD10_PDF and did the configuration. It is getting displayed (I tested only with the transaction FBL5N - customer open line items..)
Please let me know any further details on this.
Poornima -
How 2 debug a Perform subroutine in sap script
Hi,
I have a perform endperform in Script. But tht is not working in some case. i m trying to debug but i m not able to go inside the routine and see wht it is doing? . can any one help me how to debug a subroutine in sap script.Hi Panigrahi,
1) Put a break point in your perform.
2) YOu should change the dispatch option in your Output screen of the transaction which triggers your sap script. The dispatch option should be 1 (Send with a periodically scheduled job).
Then save your transaction.
3) Go to se38 and run the program RSNAST00.
Give the Object Key as the Document Number for which you are triggering the script output.
The control will stop in your perform.
Regards,
Ravi -
Include statement in SAP Scripts
HI
1)Could you send syntax of logo in header window of layout.
2)We have 2 printers, while i give the print request Purchase order, one printer is working and coming logo along with details of the form, but other printer is working, then logo is not coming in header.Please give me details as early as possible.
Thank you
sriniHi,
Command in your Sapscript
/: INCLUDE Z_YOUR_LOGO OBJECT TEXT ID 'ST' LANGUAGE 'E'
These are the steps to be followed for uploading graphics in R/3 system
1. First save the file as BMP
2. Open the BMP file in IMaging (Goto -> Programs -> Accessories -> Imaging) and
make it Zoom as 100% and save as *.TIFF
3. Open SE38 and execute program RSTXLDMC
4. Give your TIFF file path name
5. Select Bcol (for Color)
6. TEXT ID will be ZHEX-MACRO-*.
7. Inplace of * write your own logo name (ZCOMPANYLOGO)
8. Execute the program
9. Now Goto SE71 create your ZFORM
10. Create logo window
11. Goto text element of logo window
Thanks,
NN. -
Sap script perform statement.
hi all,
i have a problem with modifying standard sap script form. i have added a field in the line item of my form using perform statement in sap script. but only the corresponding to last line item is getting displayed for all.please help me on this issue my code and sap script is as follows.
**& Form material_wt
-->IN_TAB text
-->OUT_TAB text
FORM MATERIAL_WT TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : BEGIN OF IT_MAT OCCURS 0,
ZEILE LIKE J_1IEXCDTL-ZEILE,
MENGE LIKE J_1IEXCDTL-MENGE,
MATNR LIKE J_1IEXCDTL-MATNR,
NTGEW TYPE MARA-NTGEW,
END OF IT_MAT.
DATA : V_DOCNO TYPE J_1IEXCDTL-DOCNO,
V_NTWT TYPE CHAR20.
READ TABLE in_tab WITH KEY name = 'J_1IEXCDTL-DOCNO'.
CHECK sy-subrc = c_zero.
V_DOCNO = in_tab-value.
SELECT ZEILE MATNR MENGE INTO CORRESPONDING FIELDS OF TABLE IT_MAT FROM J_1IEXCDTL
WHERE DOCNO = V_DOCNO AND TRNTYP = '57FC'.
LOOP AT IT_MAT.
SELECT SINGLE NTGEW INTO IT_MAT-NTGEW FROM MARA WHERE MATNR = IT_MAT-MATNR.
modify it_mat.
ENDLOOP.
loop at it_mat.
IF not it_mat[] IS INITIAL.
READ TABLE out_tab WITH KEY name = 'NETWT'.
IF sy-subrc = 0.
V_NTWT = IT_MAT-NTGEW * IT_MAT-MENGE.
CONDENSE:V_NTWT.
out_tab-value = V_NTWT.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDIF.
endloop.
endform.
and my perform statement is as follows,
/E ITEM_VALUES
/: PERFORM MATERIAL_WT IN PROGRAM ZMM_RPT_CHALLAN
/: USING &J_1IEXCDTL-DOCNO&
/: CHANGING &NETWT&
/: ENDPERFORM
I1 &J_1IEXCDTL-ZEILE&,,&J_1IEXCDTL-MATNR&,,&NETWT&answered
-
How to write a perform in Sap Script
Hi Guys,
Can anyone let me know how to write a perform statement in Sap Script.
Thanks,
RameshI just took this example from SAP Help
=======================================
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM. -
how should i call a perform statement in SAP script
I have been trying to use it in sap script but it is giving me a dump
the code extract looks as follows:
iN DRIVER'S PROGRAM
FORM POP_ADD USING V_parvw like vbpa-parvw.
READ TABLE i_addr WITH KEY WF_PARVW = 'WE'.
ENDFORM.
IN SAP SCRIPT
/: DEFINE &V_PARVW& = &VBPA-PARVW&
/: PERFORM POP_ADD IN PROGRAM ZSD_SCR_INVOICE
/: USING &V_PARVW&
/: ENDPERFORM
/ &i_addr-WF_PARVW&
IT IS GIVING SHORT DUMP SAYING
In a subroutine call, there were more parameters than in the
routine definition.
Error in ABAP application program.
The current ABAP program "ZSD_SCR_INVOICE " had to be terminated because one of
the
statements could not be executed.
This is probably due to an error in the ABAP program.Hi,
The PERFORM in your program should have the following syntax:
FORM POP_ADD TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
READ TABLE in_tab WITH KEY 'V_PARVW'.
CHECK sy-subrc EQ 0.
ENDFORM.
Take a look at http://www.sapfans.com/forums/viewtopic.php?t=131082&highlight=perform for an example of the required syntax.
Hope this helps.
Regards -
Hi all,
I am using perform statement in sap script.
I need take a "Terms of payment" text in a PO, the length of text is 180, but when return the text to script only take the 80 first words.
The ABAP code is:
data: text(255) type c.
call function 'READ_TEXT'
exporting
id = id
language = language "sy-langu
name = name
object = object
tables
lines = tlinetab
exceptions
others = 8.
if sy-subrc = 0.
loop at tlinetab.
concatenate text tlinetab-tdline into text
separated by space.
endloop.
endif.
clear tlinetab.
refresh : tlinetab. clear tlinetab.
read table out_table with key name = 'TEXT'.
ind = sy-tabix.
write text to out_table-value.
out_table-value = out_table-value.
modify out_table index ind.
The Sap Script code is:
/: DEFINE &ZID& = 'F07'
/: DEFINE &ZOBJECT& = 'EKKO'
/: PERFORM TEXTOS IN PROGRAM ZPEDIDO
/: USING &ZOBJECT&
/: USING &ZID&
/: USING &EKKO-EBELN&
/: CHANGING &TEXT&
/: ENDPERFORM
When I´m debugging the ABAP program the value that take the variables text and out_table-value is correct, but in the script is wrong.
How I resolve this problem?
Thank for u help.
John.Hi John,
How is your variable &TEXT& declared?
If it is done as a locale variable in the SAPscript form using the "DEFINE" clause, the maximum length will be 60 characters.
Try to define a variable in your main print program. This might work better.
See also:
http://help.sap.com/saphelp_47x200/helpdata/EN/d1/8031d0454211d189710000e8322d00/content.htm
Regards,
Arjan Aalbers -
Hi Freinds,
Can You Please tell me what is the purpose of 'DEFINE' 'CHANGING' and 'USING' in sap script text.
Why we use perform statement in sap script text.
Thanks in advance.Hi Amar,
'DEFINE' is used to declare variables and assigning values to it.
Ex: DEFINE &VAR1& = 'ABC'.
DEFINE &VAR2& = SPACE.
USING and CHANGING is a part of PERFORM.
PERFORM is basically used to call a FORM which could be written in a subroutine pool. A subroutine pool is needed to fetch the data or performing commands such as 'LOOP-ENDLOOP' as script is not capable of handling it.
Thus to pass values to the FORM from PERFORM we use 'USING' and to retrive the values(the calulated one) from FORM back to PERFORM we use 'CHANGING'.
EX. DEFINE &VAR1& = '5'
DEFINE &VAR2& = '4'.
PERFORM 'SUB_CALCULATE' IN PROGRAM 'Z_ADD'
USING &VAR1&
USING &VAR2&
CHANGING &SUM&.
Here 'SUB_CALCULATE' is PERFORM name
'Z_ADD' is SUBROUTINE POOL name
Now values '5' and '4' will be paased to subroutine and logic for their sum will be written in that and it will return the value '9' to 'SUM'.
Syntax for 'FORM' will be:
FORM sub_calculate TABLES:input_sum STRUCTURE itcsy
output_sum STRUCTURE itcsy.
Reward points if helpful. -
Hi Guys,
I just wanted to clarify something.
In report if i do write break point then while running the program the system will halt there allowing me to debug.
Is this functionality possible in SAP script too??
I mean is breakpoint a valid statement in SAP Script?Hi,
1) If you want to debugg the perform then
there are 2 ways to bebug a sap script.
one by using standard program
goto se38 and ececute RSTXBUG and give ur script name debug the perform.
other one is
put a soft breat point in u r perform code(in program)
like
BREAK SAP-USER.
then when u execute u will directly goto debug mode.
2) normally you can debugg the script by
In se71, Chose from menu:
Utilities-> Activate Debugger
From the transaction, In the output message screen, you chose chose your output type, Go to Further options, Chose the dispatch option as Send at periodically scheduled jobs . then save the transaction. And run the prigram RSNAST00 It would stop at the debugging.
Regards
Kiran Sure -
Customizing Sap Script ????
I am customizing predefined form MEDRUCK and making the 3 forms ZMEDRUCK1,ZMEDRUCK2,ZMEDRUCK3 each form i am adding different fields which are not available in the predefined form.
I am using predefined print program SAPFM06P i dont want to change the predefined program, where should i write the logic for the added fields.
Thanking in advance.,
RaviHi Ravi,
CALL a PERFORM - ENDFORM from sap script and define a subroutine pool to write your own logic.
Check the links
http://www.sapdevelopment.co.uk/sapscript/sapscript_executeabap.htm
The code will be something similar.
REPORT YLSD999A.
DATA W_LENGTH TYPE I.
* GENERAL PURPOSE SUBROUTINES FOR CALLING FROM SAPSCRIPTS
FORM DISPLAY_POUND TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: COUNT TYPE P VALUE 16.
DATA: W_VALUE(17) TYPE C. "defined as 7 chars to remove pence
DATA: W_CHAR TYPE C.
DATA: W_DUMMY TYPE C.
DATA: W_CURR(3) TYPE C.
* Get first parameter in input table.
READ TABLE IN_TAB INDEX 1.
WRITE IN_TAB-VALUE TO W_VALUE .
* get second parameter in input table
READ TABLE IN_TAB INDEX 2.
MOVE IN_TAB-VALUE TO W_CURR.
IF W_CURR = 'GBP'.
W_CURR = '£'.
ENDIF.
W_LENGTH = STRLEN( W_CURR ).
* look for first space starting at right.
WHILE COUNT > -1.
W_CHAR = W_VALUE+COUNT(1).
* W_CHAR = IN_TAB-VALUE+COUNT(1).
IF W_CHAR = ' '.
COUNT = COUNT - W_LENGTH + 1.
W_VALUE+COUNT(W_LENGTH) = W_CURR.
COUNT = -1.
ELSE.
* W_VALUE+COUNT(1) = W_CHAR.
COUNT = COUNT - 1.
ENDIF.
ENDWHILE.
* read only parameter in output table
READ TABLE OUT_TAB INDEX 1.
OUT_TAB-VALUE = W_VALUE.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDFORM.
Cheers
VJ
PERFORM ... IN PROGRAM .... USING.. CHANGING ..
ENDPERFORM
To call ABAP subroutines from within a form we use the
PERFORM... IN PROGRAM ... statement , the advantage of
using it is that the print program is not required to cahnge and we
can get the new data from the subroutine which is placed in a Z
report . To pass and get the values from th subroutine the
parameters are passed which are of type structure ITCSY.
e.g. /:PERFORM get_date IN PROGRAM zreport
/:USING &SALESORDER&
/:CHANGING &S_DATE&
/:ENDPERFORM
The date &S_DATE& ....
The ABAP Code would be
REPORT zreport.
TABLES ztab.
FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab
STRUCTURE ITCSY .
READ TABLE in_tab INDEX 1.
SELECT some_date FROM ztab WHERE salesorder = in_tab-value.
IF sy-subrc EQ 0.
READ TABLE out-tab INDEX 1.
MOVE ztab-somedate TO out_tab-value
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM.
In the above code USING is used to pass the value to the
subroutine while changing is used to recieve the value from th
subroutine ,for further paramters we can use either USING or
CHANGING .
In the subroutine the type of paramter is always an internal table of
type ITCSY irrespective of the value passed.The VALUE field
of the internal table is used to fill and recieve the values .
Message was edited by: Vijayendra Rao
Maybe you are looking for
-
Time Machine Disk Full but won't delete older backups?
My Time Machine has worked since day one. And when my 1TB disk gets full, it deletes the older backups and makes room for new ones. However, since last week, it tells me there is an error, the disk is full, and I need to make room for XXXX amount of
-
Help installing Java on Windows XP Embedded (XPe)
I'm trying to deploy an embedded system running Windows XP Embedded. The application we need to run on it is written in Java and i'm having a heck of a time getting Java to work on XPe. Basically i'm building my OS image and then copying my Java Runt
-
ITunes 10.5 randomly stutters when playing music
Installed iTunes 10.5 last week to get new iOS for iPhone. I have a HP Pavillion notebook running WIndows 7 and have had no problem with iTunes before at all. Now, however, when I am playing music on iTunes little electronic glitches and stutters are
-
Security settings and problems
Hi there, I need my new airport express set at WEP (because one computer in the house is old and cannot connect with a WPA). However, when I manually set my airport to WEP, I cannot connect other computers to the network. I tried no security--the sam
-
I'm designing my first form of modest complexity. So far I'm quite successful but have one anannoyingroblem that stretches my tolerance for frustration. The form is a set of option fields. All are mandatory. The data is sent back via mail. I added a