Script: Subroutine
tables:bseg
belnr bukrs gjahr buzei hkont wrbtr
5900000010 0001 2006 001 160000 2000
5900000010 0001 2006 001 170000 2500
5900000010 0001 2006 001 180000 3000
5900000010 0001 2006 001 150000 4000
5900000010 0001 2006 001 175000 5000
5900000010 0001 2006 001 177000 150 - tds value(tax value)
the table having values like this.
here i want to read the line of hkont =177000and diaplay its corresponding wrbtr value(150).
(the hkont number b/w 177000-177999.and it is aloted
for holding tds value).
each belnr hold only one tds value.
For normal program it is working fine.can anyone pl tel me how to write subroutine for this requirement.I want to displa this value in form.pl help me out.
perform get_tds in program ztest
using &variable for hkont&
changing &variable for tds&
endperform
In ZTEST
FORM GET_TDS TABLES ITST_INTAB STRUCTURE ITCSY ITST_OUTTAB STRUCTURE ITCSY.
DATA :
P_HKONT TYPE C,
P_TDS TYPE C.
READ TABLE ITST_INTAB WITH KEY NAME = 'VARIABLE FOR HKONT'.
IF SY-SUBRC EQ 0.
P_HKONT = ITST_INTAB-VALUE.
ENDIF.
Write the logic to fetch the TDS value based on p_hkont.
IF SY-SUBRC = 0.
ITST_OUTTAB-VALUE = P_TDS.
MODIFY ITST_OUTTAB TRANSPORTING VALUE WHERE NAME = 'VARIABLE FOR TDS'.
ENDIF.
ENDFORM. "GET_TDS
Similar Messages
-
my requirement:
I want to divide the DMBTR field (currency) by MENGE field (quantity).I gave the perform endperform in script. Now i am coding the subroutine . this is what i've coded.
form f_division
TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY .
DATA : V1 TYPE BSEG-DMBTR,
V2 TYPE BSEG-MENGE,
V3(13) TYPE C,
RESULT TYPE P DECIMALS 2.
Read Table INTAB INDEX 1.
V1 = INTAB-VALUE.
Replace "," with "." into v3.
v1 = v3.
Read Table INTAB INDEX 2.
V2 = INTAB-VALUE.
Replace "," with "." into v3.
v2 = v3.
IF V2 NE 0 OR NOT V2 IS INITIAL. "for Division by 0
RESULT = V1 / V2.
ENDIF.
WRITE RESULT TO OUTTAB-VALUE LEFT-JUSTIFIED.
MODIFY OUTTAB TRANSPORTING VALUE WHERE NAME = 'TMP'.
endform.
Here i've assigned V1 to dmbtr and V2 to menge. The v3(13) is a temporary variable i introduced so that the format of dmtbr is <b>12,98</b> is changed to <u><b><u>12.98</u></b></u> .ie. the comma is changed to a point(fullstop). Now that i coded this i get an error stating "IN EXPECTED AFTER V1". plz temme how do i go abt this.hI ALL,
IF USE THE FOLLWING CODE IT WORKS.
TABLES intab STRUCTURE itcsy
outtab STRUCTURE itcsy .
DATA : v1 LIKE bseg-dmbtr,
v2 LIKE bseg-menge,
TEMP1(255) TYPE C,
TEMP2(255) TYPE C,
result TYPE p DECIMALS 2.
READ TABLE intab INDEX 1.
TEMP1 = intab-value+242(13).
v1 = TEMP1.
READ TABLE intab INDEX 2.
TEMP2 = intab-value+242(13).
v2 = temp2.
IF v2 NE 0 OR NOT v2 IS INITIAL. "for Division by 0
result = v1 / v2.
ENDIF.
WRITE result TO outtab-value LEFT-JUSTIFIED.
MODIFY outtab TRANSPORTING value WHERE name = 'TMP'.
ENDFORM. " f_division -
Subroutine in script. REWARDED
Hi All,
Please give me a sample and easy code
for calling subroutine in script
subroutine defination zprogram which is having a select statement.
every helpful answere is rewarded surely.hi priyanka,
sample code for routines in script.
/: PERFORM FORM_TEST IN PROGRAM ZTEST
/: USING &VAR1&
/: USING &VAR2&
/: USING &VAR3&
/: USING &VARN&
/: CHANGING &VAR_OUT1&
/: CHANGING &VAR_OUTN&
in the program ZTEST...
FORM FORM_TEST tables in_tab structure itcsy
out_tab structure itcsy.
Get value of VARN
data: varn like ....
read table in_tab with key name = 'VARN'.
if sy-subrc = 0.
move in_tab-value to varn.
endif.
Update the value of VAR_OUTN
read table out_tab with key name = 'VAR_OUTN'.
if sy-subrc = 0.
move <value> to out_tab-value.
modify out_tab index sy-tabix.
endif.
ENDFORM.
check this link too...
http://help.sap.com/saphelp_erp2005/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm
Regards...
Arun.
Reward points if useful. -
Problem with passing variable into subroutine
Applescript newbie stumped again...
for some reason when call the subroutine below from my code, I get an error message on the bolded variable.
Error is:
Can't make "test" into type integer.
I am calling the subroutine like this:
createFolder(folderCreationPath, appFolderName)
And am passing in two variables that I have concatenated folder name & path name.
on createFolder(folderLocation, folderName)
tell application "Finder"
if (the folder folderName of folderLocation exists) then
display dialog folderName & " already exists."
else
make new folder at folderLocation with properties {name:folderName}
end if
end tell
end createFolder
When I display the variables inside the subroutine, both appear to be strings.
Any help would be appreciated.
Thank you.If I knew how to upload a file to the forum I would do so...
Copy & paste into script editor would reformat.
Here's the full script:
---SubRoutines------------------------------------------------------------------ ------------------------------------------------------------------
on createFolder(folderLocation, folderName)
display dialog "FolderName: " & folderName & "
Folder Location: " & folderLocation & "
" & folderLocation & folderName
tell application "Finder"
if (the folder folderName of folder folderLocation exists) then
display dialog folderName & " already exists."
else
make new folder at (folderLocation as alias) with properties {name:folderName}
end if
end tell
end createFolder
---Main Code--------------------------------------------------------------------------- ------------------------------------------------------------
set projectName to "Project " & the text returned of (display dialog "What is the name of your Project?" default answer "")
set projectLocation to choose folder
---create root project folder
createFolder(projectLocation, projectName)
---create subFolders
--List of Folder names:
set FolderMediaType to {"Project", "Media & Imports", "Exports"}
set projectApplication to {"FCP", "Soundtrack", "LiveType", "Motion", "DVD Studio Pro", "Web Videos"}
set projectLocation to projectLocation & projectName --Set's project location to include project folder
repeat with iProjectApplication from 1 to count (projectApplication)
set folderCreationPath to ((projectLocation as string) & ":") --set's folderCreation to include project folder
set appFolderName to ((iProjectApplication as string) & "-" & (item iProjectApplication of projectApplication))
createFolder(folderCreationPath, appFolderName)
set folderCreationPath to projectLocation & ":" & appFolderName & ":"
repeat with iFolderMediaType from 1 to count (FolderMediaType)
set mediaFolderName to iFolderMediaType & "-" & (item iFolderMediaType of FolderMediaType)
createFolder(folderCreationPath, mediaFolderName)
end repeat
end repeat -
Error while sending data to a subroutine in script
Hi,
While passing a currency field for calculation to a subroutine through perform statement iam getting runtime error saying "unable ti interpret 5000.00 as a number. 5000.00 is nothing but the first currency value which iam sending for calculation.in the code the error is raised on the bold line .
rf140-wrshb has value 5000.00 .the code which i have written in subroutine is as follows.
READ TABLE I_IN WITH KEY NAME = 'RF140-WRSHB'.
MOVE I_IN-VALUE TO LV_SUM1.
CLEAR I_IN.
DATA: SUM_C TYPE N.
SUM1 = SUM1 + LV_SUM1.
READ TABLE I_OUT WITH KEY NAME = 'LV_BALANCE'.
MOVE SUM1 TO I_OUT-VALUE.
MODIFY I_OUT TRANSPORTING VALUE WHERE NAME = 'LV_BALANCE'.
CLEAR I_OUT.
lv_balance is the one which receives the output value.
can anyone tell me what is the mistake i have done nd how to rectify it.
Thanks,
Rose.Hi,
I have done something similar so below is the code while passing currency fields to subroutines:
Actually I was retrieving 2 fields from scripts and then substract them and then send back the result to the script. Hope it works out for you, try it out and REWARD POINTS IF HELPFUL!! (also for your prev post!!)
FORM get_pay TABLES in_tab STRUCTURE itcsy out_tab STRUCTURE itcsy.
DATA: lv_var(255) TYPE c, "dmbtr,
lv_var1(255) TYPE c, "qsshb,
lv_var2(255) TYPE c, "dmbtr.
var(20) TYPE c,
var1(25) TYPE c,
var2(25) TYPE c,
var3(25) TYPE c,
var4(25) TYPE c,
var5(25) TYPE c,
var6(25) TYPE c,
vari TYPE ztemp,
vari2 TYPE ztemp,
vari3 TYPE ztemp.
DATA: lv_var4 TYPE dmbtr,
lv_var5 TYPE qsshb,
lv_var6 TYPE dmbtr,
len TYPE i,
len1 TYPE i,
dot TYPE c.
READ TABLE in_tab WITH KEY 'REGUP-DMBTR'.
IF sy-subrc EQ 0.
lv_var = in_tab-value.
len = STRLEN( lv_var ).
len1 = len - 3.
dot = lv_var+len1(1).
IF dot = ','.
SPLIT lv_var AT ',' INTO var1 var2.
REPLACE '.' IN var1 WITH ','.
CONCATENATE '.' var2 INTO var2.
CONCATENATE var1 var2 INTO var.
CONDENSE var.
vari = var1.
SHIFT vari LEFT DELETING LEADING '0'.
CONCATENATE vari var2 INTO vari.
lv_var4 = vari.
ELSE.
SPLIT lv_var AT '.' INTO var1 var2.
REPLACE '.' IN var1 WITH ','.
CONCATENATE '.' var2 INTO var2.
CONCATENATE var1 var2 INTO var.
CONDENSE var.
vari = var1.
SHIFT vari LEFT DELETING LEADING '0'.
CONCATENATE vari var2 INTO vari.
lv_var4 = vari.
ENDIF.
CLEAR: dot, len, len1.
ENDIF.
lv_var = vari.
CALL FUNCTION 'CHAR_NUMC_CONVERSION'
EXPORTING
input = lv_var
IMPORTING
numcstr = lv_var4.
READ TABLE in_tab WITH KEY 'REGUP-QBSHB'.
IF sy-subrc EQ 0.
lv_var1 = in_tab-value.
len = STRLEN( lv_var1 ).
len1 = len - 3.
dot = lv_var1+len1(1).
IF dot = ','.
SPLIT lv_var1 AT ',' INTO var3 var4.
REPLACE '.' IN var3 WITH ','.
CONCATENATE '.' var4 INTO var4.
CONDENSE var.
vari2 = var3.
SHIFT vari2 LEFT DELETING LEADING '0'.
CONCATENATE vari2 var4 INTO vari2.
lv_var6 = vari2.
ELSE.
SPLIT lv_var1 AT '.' INTO var3 var4.
REPLACE '.' IN var3 WITH ','.
CONCATENATE '.' var4 INTO var4.
CONDENSE var.
vari2 = var3.
SHIFT vari2 LEFT DELETING LEADING '0'.
CONCATENATE vari2 var4 INTO vari2.
lv_var6 = vari2.
ENDIF.
CLEAR: dot, len, len1.
ENDIF.
lv_var1 = vari2.
CALL FUNCTION 'CHAR_NUMC_CONVERSION'
EXPORTING
input = lv_var1
IMPORTING
numcstr = lv_var6.
lv_var5 = lv_var4 - lv_var6.
lv_var2 = lv_var5.
var = lv_var5.
WRITE lv_var5 TO var CURRENCY 'SG'.
READ TABLE out_tab WITH KEY 'LV_PAY'.
IF sy-subrc EQ 0.
out_tab-value = var.
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM. "get_PAY
Regards,
Narendra. -
How can i get address from subroutine program in script window
Hi All,
I have a problem with my script that is can i go into debug mode in script with out using the print program, but i have script code which i want to see is in the separate subroutine pool program.
Regards.
Venkat NYou can activate debugger in transaction SE71 - Script layout.
-
How to pass a value of 130 odd characters from a subroutine to a script
Hi Friends,
I am passing a value of 130 odd characters(say) from subroutine to script through ITCSY structure (VALUE- 255 characters), however, while debugging the script I find that the whole length is not getting passed into the script.
Is this a limitation, or is there any solution to this?
Thanks and Regards,
Birendra ChatterjeeHi,
Check the size of that Window in which you are displaying this Text of 130 characters.
May be it is less
in that case split that string into 2 strings and pass the two strings from ITCSY structure to script and use.
reward if useful
regards,
ANJI -
Using Subroutines in SAP script
Hi Experts,
I am trying to get value of Z variables from a subroutine pool program using Perform ... EndPerform in my sap script form.
In my form window i have written
PERFORM ITEM_LINE_2F IN PROGRAM ZMEPRINTFORMS
USING &EKPO-MENGE&
CHANGING &V_EKPO_MENGE&
ENDPERFORM
and in my subroutine pool program i have written:
FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
out_par structure itcsy.
data : ZLV_ekpo_menge(17),
v_ekpo_menge(17),
ZLV_temp_split_1(14),
ZLV_temp_split_2(3),
ZLV_temp_menge(8) type p.
constants: zc_menge type TDTPRGNAME value 'EKPO-MENGE'.
field-symbols: <tab> type itcsy.
loop at in_par assigning <tab>.
case <tab>-name.
when zc_menge.
zlv_ekpo_menge = <tab>-value.
when others.
endcase.
endloop.
unassign <tab>.
V_EKPO_MENGE = zlv_ekpo_menge.
SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
ZLV_TEMP_MENGE = zlv_ekpo_menge.
WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
ELSE.
WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
ENDIF.
loop at out_par assigning <tab>.
case <tab>-name.
when V_EKPO_MENGE.
<tab>-value = v_ekpo_menge.
when others.
Modify out_par.
endcase.
endloop.
unassign <tab>.hi,
FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
out_par structure itcsy.
data : ZLV_ekpo_menge(17),
v_ekpo_menge(17),
ZLV_temp_split_1(14),
ZLV_temp_split_2(3),
ZLV_temp_menge(8) type p.
read table in_par index 1.
V_EKPO_MENGE = zlv_ekpo_menge = in_par-value.
SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
ZLV_TEMP_MENGE = zlv_ekpo_menge.
WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
ELSE.
WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
ENDIF.
read table out_par index 1.
out_par-value = v_ekpo_menge.
Modify out_par.
but frankly speaking... i dint understand your logic... finally you are passing the same value ????????
regards
padma -
Hi folks,
i want to print purchase order number and document date in purchase order form in seprate window.the purchase order number iam giving in selection-screen that number i want to display. for this iam writing code in subroutine.but the data is not fetching.
can u please provide me sample coding or example for this.
Thx in advance,
Neelima.NHi,
Are you using Standard Script copied or created your own one.
If standard script copied with standard print program, in your created window, give this values &EKKO-EBELN&&' / 'EKKO-BEDAT&
If Custom created script, in the Window give the selection field declared for EBELN and for BEDATin driver program.
&P_EBELN& &P_BEDAT&
Regards
Bala Krishna -
HOw can we Call Subroutine in Sap Script?
HOw can we Call Subroutine in Sap Script?
Hi
*You have to call sub routine from script like this.
/: PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
/: USING &RM06P-LFDAT&
/: USING &PEKKO-LFDAT&
/: CHANGING &VALUE_OLD&
/: CHANGING &VALUE_NEW&
/: ENDPERFORM
*In print program write code.
FORM date_format TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : date TYPE char10.
DATA : date2 TYPE char10.
DATA : l_dmbtr TYPE char10.
READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
IF sy-subrc = 0.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
IF sy-subrc = 0.
l_dmbtr = in_tab-value.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_NEW'.
IF sy-subrc EQ 0.
out_tab-value = date2.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_OLD'.
IF sy-subrc = 0.
out_tab-value = l_dmbtr.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDFORM. "DATE_FORMAT -
How to call a subroutine in a script ?
Hi ,
How to call a subroutine in a script ?
bye,
Satya.Hello,
Syntax goes like this
/: 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.
Example:
In script form
/: PERFORM READ_TEXTS IN PROGRAM 'Z08M1_FORM_EKFORM1'
/: USING &EKKO-EKORG&
/: USING &EKPO-WERKS&
/: USING &EKKO-EKGRP&
/: USING &EKKO-BSTYP&
/: CHANGING &COMPNAME&
/: CHANGING &SENDADR&
/: CHANGING &INVCADR&
/: CHANGING &COMPADR&
/: CHANGING &COVERLTR&
/: CHANGING &SHIPADR&
/: CHANGING &REMINDER&
/: CHANGING &REJECTION&
/: CHANGING &POSTADR&
/: CHANGING &LOGO&
/: ENDPERFORM
In program
FORM Read_texts - To extract the standard texts from the table *
FORM READ_TEXTS TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA : L_EKORG TYPE EKORG,
L_WERKS TYPE WERKS_D,
L_BSTYP TYPE BSTYP,
L_EKGRP TYPE BKGRP.
READ TABLE IN_PAR WITH KEY 'EKKO-EKORG' .
CHECK SY-SUBRC = 0.
L_EKORG = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKPO-WERKS' .
CHECK SY-SUBRC = 0.
L_WERKS = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-EKGRP' .
CHECK SY-SUBRC = 0.
L_EKGRP = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-BSTYP' .
CHECK SY-SUBRC = 0.
L_BSTYP = IN_PAR-VALUE.
CLEAR Z08M1_ORG_TEXTS.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = L_BSTYP.
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = SPACE.
ENDIF.
READ TABLE OUT_PAR WITH KEY 'COMPNAME'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COMP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SENDADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_ADRS.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'INVCADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_INVC.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COMPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_CPAD.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COVERLTR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COVR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SHIPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_SHIP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REMINDER'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RMDR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REJECTION'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RJCT.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'POSTADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_POST.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'LOGO'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_LOGO.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Hope this helps.
Regards -
Script external subroutine for multiple fileds display
Hi,
can anybody tell
how to write external subroutine in script.
i want to display multiple fields data in script by using external subroutine.
Regards,
Kumar.HI,
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
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.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM -
hi!
We know that subroutines are possible in main window of script.
Is it possible to write subroutines in constant and variable windows as well?Hi,
subroutines can be called with in all windows
of sapscript
perform add in progarm(ztest) using a b .
Regards
amole -
Subroutine call from SAP Script
Hi,
I need to calculate required/outstanding qty. hence am passing existing values of reservation#/item# and issued qty.
both req/out qty are returned blank by the code. please help.
Following is my code segment for a external routine call from SAP Script.
/: PERFORM P_GET_QTY IN PROGRAM ZTEST
/: USING &MSEG-RSNUM&
/: USING &MSEG-RSPOS&
/: CHANGING &REQ_QTY&
/: CHANGING &MSEG-MENGE&
/: CHANGING &OUT_QTY&
/: ENDPERFORM
REPORT ztest .
TABLES resb.
DATA: wa_resb TYPE resb,
req_qty TYPE resb-bdmng,
isd_qty TYPE mseg-menge,
out_qty TYPE resb-bdmng.
FORM p_get_qty TABLES input STRUCTURE itcsy
output STRUCTURE itcsy.
DATA: avlbl TYPE resb-bdmng.
READ TABLE input WITH KEY 'MSEG-RSNUM'.
CHECK sy-subrc = 0.
wa_resb-rsnum = input-value.
READ TABLE input WITH KEY 'MSEG-RSPOS'.
CHECK sy-subrc = 0.
wa_resb-rspos = input-value.
READ TABLE input WITH KEY 'REQ_QTY'.
CHECK sy-subrc = 0.
req_qty = input-value.
READ TABLE input WITH KEY 'MSEG-MENGE'.
CHECK sy-subrc = 0.
isd_qty = input-value.
SELECT SINGLE * INTO wa_resb
FROM resb
WHERE rsnum = wa_resb-rsnum
AND rspos = wa_resb-rspos.
CHECK sy-subrc = 0.
avlbl = wa_resb-bdmng - wa_resb-enmng.
req_qty = avlbl - out_qty.
out_qty = req_qty - isd_qty.
output-name = 'REQ_QTY'.
output-value = req_qty.
MODIFY output TRANSPORTING name value WHERE name = 'REQ_QTY'.
APPEND output.
output-name = 'OUT_QTY'.
output-value = out_qty.
MODIFY output TRANSPORTING name value WHERE name = 'OUT_QTY'.
APPEND output.
ENDFORM.
Thanks,
Ram.Hi Ram,
I think you have to use MODIFY instead of append for the OUTPUT table.
MOdify the table with KEY. This should resolve the problem.
Ram, you can check this code and see how the MODIFY is to be used.
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 -
how can i call subroutine in SAP Script?& where?
hi,
refer d links
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/calling%2ba%2bsub-routine%2bin%2bsap%2bscripts
subroutine in script. REWARDED
abput subroutines in scripts
How to call a subroutine in a script ?
How to call subroutine in a sap script
Maybe you are looking for
-
Best iTunes strategy for a family with multiple Windows accounts
On our previous Windows 7 PC, I set up separate Windows accounts for each of our family members. Since iTunes can't be run concurrently on more than one Windows account, I also set up another Windows account named "iTunes," the sole purpose of which
-
I have already go to properties then resources and try to remove resource option but it was't working.so help me by giving another technique to solve this issue.
-
Aceess a class in the Tomcat 5.0\work\Catalina\localhost
Hi I need to access a jsp variable in another class. How do i do that. I know that tomcat converts the jsp calss into a java file and puts them in the work\Catalina\localhost folder. So how do i get the variable from the jsp converted java class to m
-
Hi Everybody, i hope someone can help me. I had an Gantt Chart. This Gantt shows for example Absence from employees. When it is a absence about one complete day it looks finde. But when its a absence for example the halff day from 12 am till 3 pm tha
-
I want to create a slideshow in dreamweaver cs6..but my Widget browser is not responding..what should I do?