Calling subroutines from SAPScript
Hi all,
I have added a piece of code in my MAIN window which calls a subroutine in another program. This works just fine. However, when I moved the code from one <b>window element</b> of MAIN to another, the code is no longer triggered.
What causes this to happen? Is it related to the calling of function module WRITE_FORM in the application program? Any ideas?
All helpful answers will be rewarded!
Regards,
M.V.
Hi,
In some case we need to do some mathematical operations in scripts !! Those things we cant do in Script Editor !! thats y the subroutines are there in scripts !!
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.
Regards
Rama.Pammi
Similar Messages
-
Problem in calling ABAP Subroutine from SAPSCRIPT
Hi,
I need to get the reason for cancellation of a Business Even in Training & Event Management module, so I am passing Emp_id.
But the reason(CAAATRT) is returned with blank by the code.
please help.
/:DEFINE &EMP_ID&= &PPVAR-TOBJD&
/:PERFORM HR_REASON_PRINT IN PROGRAM ZHR_REASON_PRINT
/:USING &EMP_ID&
/:CHANGING &CAATRT&
REPORT ZHR_REASON_PRINT.
DATA : BEGIN OF in_par OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF in_par.
DATA : BEGIN OF out_par OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF out_par.
DATA: TOBJD TYPE PPVAR-TOBJD,
ADATANR TYPE HRP1001-ADATANR,
CAATR TYPE HRPAD25-CAATR,
CAATRT TYPE T77CART-CAATRT,
EMP_ID TYPE C.
TABLES : PPVAR,
HRP1001,
HRPAD25,
T77CART.
FORM HR_REASON_PRINT TABLES input output.
in_par[] = input[].
out_par[] = output[].
READ TABLE in_par INDEX 1.
CHECK sy-subrc = 0.
TOBJD = in_par-value.
MOVE in_par-value TO TOBJD.
SELECT ADATANR
into ADATANR
FROM HRP1001
WHERE OBJID EQ TOBJD.
ENDSELECT.
SELECT CAATR
into CAATR
FROM HRPAD25
WHERE ADATANR EQ ADATANR.
ENDSELECT.
SELECT CAATRT
INTO CAATRT
FROM T77CART
WHERE CAATR EQ CAATR.
ENDSELECT.
REFRESH out_par.
out_par-name = 'DREASON'.
move CAATRT To out_par-value.
MODIFY out_par INDEX 1.
APPEND out_par.
output[] = out_par[].
Thanks
RamakrishnaHi ramakrishna,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
2.
FORM abc
TABLES
in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
ENDFORM.
3. The perform in se38 program should be of the
above format only.
4. We cannot pass internal tables.
5. Rather we need to pass
VARIABLE NAME
VARIABLE VALUE
(see the structure of itcsy in se11)
6. In this form, we have to read
the internal table in_tab
to capture the variable name and its value.
7. Similary, to return the values,
we have to put one record (for each variable)
in out_tab.
regards,
amit m. -
Hi. how to create Subroutine Pool and call it from sapscript
HI,
Can anyone tell is there any standard subroutine pool available which could fetch the customer number.
how to create an subroutine pool and call it from the sapscript..
please help me
Advance Thanks..
Guhapriyan.Hi Guhapriyan,
1. Create a FORM in your program.
2. call it from sapscript using
/: PERFORM GET_COMPANY_INFO IN PROGRAM YHRR_OFFER_CONTRACT_FORM
/: USING &P0001-BUKRS&
/: CHANGING &COMP_NAME&
/: ENDPERFORM
3. The form in your program should be of the following parameters only.
form GET_COMPANY_INFO tables IN_PAR structure ITCSY
OUT_PAR structure ITCSY.
(important is IN_PAR, OUT_PAR -
where in your read the values passed,
and pass back the values
thru internal table using varname, varvalue)
regards,
amit m. -
How to Call Function from SAPSCRIPT
I want to Call a function from my SAPSCRIPT to get some data and print the same in the form , Can I get an example for this
Hi Nandan,
U cannot directly call function from SAPScript... For that u have to create one include in which u need to write the code. Using Perform... EndPerform u can call the same from SAPScript. See the below example
u need to write this code in SAPScript
PERFORM formname IN PROGRAM includename
USING &field1&
USING &field2&
CHANGING &field3&
ENDPERFORM
Here includename is your include type program.
u need to write this code in your include type program..
FORM formname TABLES in_par STRUCTURE itcsy
out_par STRUCTURE itcsy.
data : var1 like field1,
var2 like field2,
var3 like field3.
READ TABLE in_par WITH KEY 'field1'.
CHECK sy-subrc = 0.
var1 = in_par-value.
READ TABLE in_par WITH KEY 'field2'.
CHECK sy-subrc = 0.
var2 = in_par-value.
now u can call corresponding function using local VAR1 and VAR2. Here u can pass N no of USING parameters.
After processing on VAR3...
READ TABLE out_par WITH KEY 'field3'.
out_par-value = VAR3.
MODIFY out_par INDEX sy-tabix.
EndForm.
Here in_par and out_par are the structures which will be used to communicate with SAPScript. And this is the only way as per my view.
I m sure this code will work fine. Here i have used dummy variables that u need to change as per your requirement. If u have more queries write me back.
And yes if this works than dont forget to give the points.
Regards,
Sagar -
Calling subroutine in sapscript
can anyone guide how 2 call subrouting in sapscript and i need sample code...i need a simple code how 2 call and implement
so tat it ll be easy 4 me learn..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.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
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.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
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.
regards,
veeresh -
Hi ,
I am facing some problem in calling a subroutine from Standard Text element (Txn SO10).
I have done the following in a text element.
/: DEFINE &GD_PREV_NAME& = ''
/: PERFORM GET_PREV_NAME IN PROGRAM ZTEST
/: USING &P0001-PERNR&
/: USING &P0002-BEGDA&
/: CHANGING &GD_PREV_NAME&
/: ENDPERFORM
In the ABAP ZTEST,
FORM get_prev_name TABLES tabin STRUCTURE itcsy
tabout STRUCTURE itcsy.
DATA : ld_pernr LIKE pa0001-pernr.
READ TABLE tabin WITH KEY name = 'P0001-PERNR'.
IF sy-subrc = 0.
ld_pernr = tabin-value.
ENDIF.
ENDFORM.
I found in debugging that the both tables TABIN & TABOUT are empty in the FORM get_prev_name !!!!
Can anyone hint on why the values are not passed to ABAP ??
Many thanks in advance.
Regards,
Sandip.
Ph : +44 121 683 2814.Hi Sandip,
I guess the problem here might be that the values aren't getting flown.
First try this (hardcoding and testing),
/: DEFINE &GD_PREV_NAME& = ''
/: PERFORM GET_PREV_NAME IN PROGRAM ZTEST
/: USING '1000'
/: USING '20050101'
/: CHANGING &GD_PREV_NAME&
/: ENDPERFORM
if it works fine, then figure out whether the variables P0001-PERNR AND P0002-BEGDA are not null when passed. If not then try this
/: DEFINE &GD_PREV_NAME& = ''
/: PERFORM GET_PREV_NAME IN PROGRAM ZTEST
/: USING &P0000-PERNR&
/: USING &P0002-BEGDA&
/: CHANGING &GD_PREV_NAME&
/: ENDPERFORM
ELSE TRY PA0000-PERNR AND PA0002-BEGDA
Cheers,
Sam. -
Calling subroutine from SAP script
I am using the below code within my SAP script form that prints GR/GI Slips but its not working. And the only way I can issue the output is from MB02 whcih doesn't seem to allow to call the debuger, so I'm at a lost as to what to do.
Code in SAP script
/: PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
USING &MSEG-MATNR&
/: USING &MSEG-LGNUM&
/: CHANGING &MABDR-LGPBE&
/: ENDPERFORM
CODE from my subroutine program:
FORM get_bins TABLES input_table STRUCTURE itcsy
output_table STRUCTURE itcsy.
DATA: lc_matnr TYPE matnr,
lc_lgnum TYPE lgnum,
lc_lgpla TYPE lgpla,
lc_index TYPE sy-tabix.
* Material no
READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
MOVE input_table-value TO lc_matnr.
* Warehouse number
READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
MOVE input_table-value TO lc_lgnum.
* Get BIN
SELECT SINGLE lgpla INTO lc_lgpla
FROM mlgt
WHERE matnr = lc_matnr
AND lgnum = 'CPT' "lc_lgnum
AND lgtyp = '001'.
IF sy-subrc = 0.
READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
lc_index = sy-tabix.
MOVE lc_lgpla TO output_table-value.
MODIFY output_table INDEX lc_index.
ENDIF./: PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
/: USING &MSEG-MATNR&
/: USING &MSEG-LGNUM&
/: CHANGING &MABDR-LGPBE&
/: ENDPERFORM
FORM get_bins TABLES input_table STRUCTURE itcsy
output_table STRUCTURE itcsy.
DATA: lc_matnr TYPE matnr,
lc_lgnum TYPE lgnum,
lc_lgpla TYPE lgpla,
lc_index TYPE sy-tabix.
Material no
READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
MOVE input_table-value TO lc_matnr.
Warehouse number
READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
MOVE input_table-value TO lc_lgnum.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lc_matnr
IMPORTING
OUTPUT = lc_matnr .
Get BIN
SELECT SINGLE lgpla INTO lc_lgpla
FROM mlgt
WHERE matnr = lc_matnr
AND lgnum = 'CPT' "lc_lgnum
AND lgtyp = '001'.
IF sy-subrc = 0.
READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
lc_index = sy-tabix.
MOVE lc_lgpla TO output_table-value.
MODIFY output_table TRANSPORTING VALUE WHERE NAME = 'MABDR-LGPBE'.
ENDIF. -
Calling subroutine from scripts
I am calling a subroutine form a standard text, the subroutine is getting called but the input table is comming empty.
can any one please advise me what could be the problem.
/:PERFORM GET_APP_DATA IN PROGRAM YHR_APP_DATA
/:USING &P0001-PERNR&
/:CHANGING &GRADE&
/:ENDPERFORMCheck this sample code...may be it will help u to identify the prob...
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
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 u2018PAGEu2019.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018NEXTPAGEu2019.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = u2018|u2019. "First page
ELSE.
OUT_PAR-VALUE = u2018||u2019. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Regards,
JOy. -
Error while calling Subroutine from Script
HI Friends,
I am getting a short dump whilecalling a suboutine from Script.
Please suggest if am wrong with below code
/: PERFORM GET_ADDRESS IN PROGRAM ZSUBROUTINES
/: USING &MHND-KUNNR&
/: CHANGING &ADRS-LINE0&
/: CHANGING &ADRS-LINE1&
/: ENDPERFORM
All above fields are available in script window
In the program
FORM get_address TABLES in_tab STRUCTURE itcsy
out_tab stucture itcsy.
ENDFORM.
ThanksHI,
Your code is correct, in the FORM and ENDFORM in the program, read the INPUT table and get the values and write your logic using these values and send back the values to the SCRIPT using the OUTTABLE. here you need to use the MODIFY statment for the outtable using Sy-TABIX.
Regards
Sudheer -
Sapscript calling forms from program
Hi experts
I need to write a form in a program to get values.
Here is my code. But i cant seem to succesfully compile it. Need help. I want to take
ernam from sapscript and send name and lastname back. Can u please fill the function.
Also i have an error says itcyy is not a structure ?
thanks.
REPORT ZME23N_SAPSCR_FM.
tables : user_Addr.
form get_Values TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
*READ TABLE IN_PAR WITH KEY 'ERNAM'.
*data firstname like user_addr-name_first.
*select single * from user_Addr
*where bname = ernam.
*firstname = user_Addr-name_first.
*lastname = user_addr-name_last.
endform.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.
The system does not execute the PERFORM command within
SAPscript
replace modules, such as TEXT_SYMBOL_REPLACE or
TEXT_INCLUDE_REPLACE.
The replace modules can only replace symbol values or
resolve include
texts, but not interpret SAPscript control commands.
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.
The values of the SAPscript symbols passed with /: USING...
are now
stored in the internal table IN_TAB . Note that the system
passes the
values as character string to the subroutine, since the
field Feld
VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR
80). See the
example below on how to access the variables.
The internal table OUT_TAB contains names and values of the
CHANGING
parameters in the PERFORM statement. These parameters are
local text
symbols, that is, character fields. See the example below
on how to
return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in
the ABAP
program QCJPERFO is called. Then the simple barcode
contained there
('First page', 'Next page', 'Last page') is printed as
local variable
symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
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. -
How to call a subroutine from sap script
hi friends,
Can anybody tell me How to call a subroutine from sap script .
thanks n regards .
Maheshhi..
Calling ABAP Subroutines: PERFORM
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.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
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.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
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.
regards,
veeresh -
Calling subroutine​s from dll
I am trying to call routines from a vendor supplied dll. They helpfully gave me a header file, but little else. The header of the subroutine that I'm trying to call reads:
_LYDYAQCW_API DWORD GetSysVersion(WORD* version, WORD* release, WORD* patch, DWORD DriverHandle);
I interpreted the DWORD as U32, and WORD as U16 with * as "point to value". Running the VI causes LabVIEW to disappear instantly with not-so-much as a whisper. Can anyone help, with this problem and more generally, how to interpret the datatypes in Windows APIs. The one document I have found does not have these types.
Thanks,
Damian
Attachments:
LaseLecTmp.vi 14 KBWise Owl wrote:
> Rolf, thanks for your help in this matter. Immediately, by changing
> the calling convention to C, LabVIEW does not crash. There is a
> InitDriver function that it looks like I should call. However, the
> handle is defined by "LPDWORD DriverHandle". Does this not imply that
> the value is passed, making it impossible for the function to pass
> back a handle? Do you have any idea how I can find a lookup table to
> translate LPDWORD, WORD, etc. into LabVIEW specific byte counts?
Well, if you are familiar with C you can look at the Windows SDK headers
to find out what they mean. Most of these basic types are defined in
WinDef.h.
A short explanation
LP stands for Long Pointer meaning a 32 bit pointer (pass as pointer)
P sta
nds for Pointer (meaning the same as LP in modern Windows at least
until we get 64 bit Windows.)
BYTE is an unsigned 8 bit integer
WORD is an unsigned 16 bit integer
DWORD or UINT is an unsigned 32 bit integer
CHAR is a signed 8 bit integer
SHORT a signed 16 bit integer
LONG or INT a signed 32 bit interger
BOOL a boolean (a 32 bit integer in fact)
HANDLE (and almost any type starting with H..) a handle (just treat it
as 32 bit unsigned int)
So in your case the parameter LPDWORD would mean to configure an
unsigned 32 bit integer which should be passed by reference (as pointer).
> Making a call to this function produces an exception which stops the
> Call Library Function Node. Probably because I have the wrong
> variable types defined.
If you configure the parameter to be passed as value (not a pointer)
this would be what should happen.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Subroutine in sapscript for net due date
Hi,
This is the first time I am creating a subroutine for sapscript and I could not get it to work. I need to calculate the net due date using the baseline date plus cash discount days. But the form is just printing out 0000000. I am just trying to extract one due date here but I will have to get it for all line items then sort descending to get the latest one. Can anyone help me to see the gap why this is not working?
In the sapscript I have the following:
DEFINE &BASEDATE& = ®UP-ZFBDT&
DEFINE &PAYTERMS& = ®UP-ZBD1T&
PERFORM NET_DUE_DATE IN PROGRAM Z_SAPSCRIPT_FUNCTIONS
USING &BASEDATE&
USING &PAYTERMS&
CHANGING &DUEDATE&
ENDPERFORM
In program Z_SAPSCRIPT_FUNCTIONS
Thanks in advance!
CholenHi Raju!
I am really getting close! I did the conversion for all variables, however for VBLNR, it does not work. It gives leading zeroes but the value starts with a 'P' before the zeroes and the numeric value. I tried to remove that from the where clause and my select finally got something. However the output on the form is in the internal format. I suppose I should use CONVERT_DATE_TO_EXTERNAL which I tried doing after out_tab-value = lv_netduedate which is the variable I am passing to the form.
Raju Shrestha wrote:
Hi Cholen,
I believe your lv_laufd is a 10 character field in format MM/DD/YYY or DD/MM/YYYY. You should move that data to a 8 character variable (say lv_date) in YYYYDDMM format.
Please try this conversion
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = lv_laufd
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
Check in debug, you should get lv_date in YYYYMMDD. Now use lv_date in your WHERE clause.
If you still do not get data after lv_date eq YYYYMMDD, check your LIFNR and KUNNR. They should be 10 charaters with leading zeroes if not 10 .
If needed use the conversion for lv_lifnr and lv_kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
date_external = lv_lifnr
IMPORTING
date_internal = lv_lifnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
date_external = lv_kunnr
IMPORTING
date_internal = lv_kunnr.
Cheers,
Raju. -
sir,
Like to know How we pass subroutine in sapscript and how standard texts are added and what is its command and transaction.
Edited by: Alvaro Tejada Galindo on Apr 28, 2008 4:45 PMSubroutines in scripts:
Calling ABAP Subroutines: PERFORM
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.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
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.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
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. -
Calling form from layout.
In a layout, I have the following perform statement :
PERFORM CONVERT_CURRENCY IN PROGRAM Z_SCRIPT_INVOICE
USING &ZRATE&
USING &ZKBETR&
USING &ZKWERT&
USING &ZCURRENCY&
USING &VBDKR-WAERK&
USING &VBDKR-BUKRS&
USING &KOMVD-KAWRT&
USING &VBDKR-VKORG&
USING &VBDKR-LAND1&
CHANGING &ZPRICE&
CHANGING &ZAMOUNT&
ENDPERFORM.
But form statement is as follows:
FORM convert_currency TABLES input_tab STRUCTURE itcsy
output_tab STRUCTURE itcsy.
ENDFORM.
- Plz explain how the parameter is matched between form & perform?Hi
The program Name in the PERFORM is Z_SCRIPT_INVOICE
So in SE38 You will create this program and in that you will write the FORM..ENDFORM.
So when the PERFORM is executed it calls the PROGRAM in SE38 and the form is called.
In form you write READ Table IN_PAR with key 'ZRATE'.
See the sample code
How to call a subroutine form SAPscripts
The Form :
/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
/:USING &EKKO-EBELN&
/:CHANGING &CDECENT&
/:ENDPERFORM
The report :
REPORT zkrpmm_perform_z1medruck .
DATA : BEGIN OF it_input_table OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_input_table.
déclaration de la table output_table contenant les
variables exportées
DATA : BEGIN OF it_output_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_output_table.
DATA : w_ebeln LIKE ekko-ebeln,
w_vbeln LIKE vbak-vbeln,
w_zcdffa LIKE vbak-zcdffa.
FORM CDE_CENT
FORM cde_cent TABLES input output.
it_input_table[] = input[].
it_output_table[] = output[].
READ TABLE it_input_table INDEX 1.
MOVE it_input_table-value TO w_ebeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_ebeln
IMPORTING
output = w_ebeln.
SELECT SINGLE zcdffa FROM ekko
INTO w_zcdffa
WHERE ebeln = w_ebeln.
it_output_table-name = 'CDECENT'.
MOVE w_zcdffa TO it_output_table-value.
MODIFY it_output_table INDEX 1.
output[] = it_output_table[].
ENDFORM.
/: PERFORM
/: 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.
REPORT ZMPO1 .
form get_freight tables in_par structure itcsy out_par structure itcsy.
tables: ekko,konv,t685t.
data: begin of itab occurs 0,
ebeln like ekko-ebeln,
knumv like ekko-knumv,
end of itab.
data: begin of itab1 occurs 0,
knumv like konv-knumv,
kposn like konv-kposn,
kschl like konv-kschl,
kbetr like konv-kbetr,
waers like konv-waers,
kwert like konv-kwert,
end of itab1.
data: begin of iout occurs 0,
kschl like konv-kschl,
vtext like t685t-vtext,
kbetr like konv-kbetr,
kwert like konv-kwert,
end of iout.
data v_po like ekko-ebeln.
read table in_par with key 'EKKO-EBELN'.
if sy-subrc = 0.
v_po = in_par-value.
select
ebeln
knumv
from ekko
into table itab
where ebeln = v_po.
if sy-subrc = 0.
loop at itab.
select
knumv
kposn
kschl
kbetr
waers
kwert
into table itab1
from konv
where knumv = itab-knumv and
kappl = 'M'.
endloop.
loop at itab1.
if itab1-kposn <> 0.
select single * from t685t
where kschl = itab1-kschl
and kappl = 'M'
and spras = 'EN'.
iout-vtext = t685t-vtext.
iout-kschl = itab1-kschl.
iout-kbetr = itab1-kbetr.
iout-kwert = itab1-kwert.
append iout.
clear iout.
endif.
endloop.
sort itab1 by kposn.
loop at iout.
sort iout by kschl.
if ( iout-kschl eq 'GSDC' OR
iout-kschl eq 'GSFR' OR
iout-kschl eq 'GSIR' ).
at end of kschl.
read table iout index sy-tabix.
sum.
write:/ iout-kschl,iout-vtext,iout-kwert.
out_par-name = 'A1'.
out_par-value = iout-vtext.
append out_par.
out_par-name = 'A2'.
out_par-value = iout-kwert.
append out_par.
endat.
endif.
endloop.
endif.
endif.
endform.
IN THE FORM I AM WRITING THIS CODE.
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:ENDPERFORM
&A1&
&A2&
This Code is to be written in the PO form under ADDRESS window.
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:DEFINE &A3& = ' '
/:DEFINE &A4& = ' '
/:DEFINE &A5& = ' '
/:DEFINE &A6& = ' '
/:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:CHANGING &A3&
/:CHANGING &A4&
/:CHANGING &A5&
/:CHANGING &A6&
/:ENDPERFORM
&A1&
&A2&
&A3&
&A4&
&A5&
&A6&
Regards
Anji
Maybe you are looking for
-
Help with if statement for a beginner.
Hello, Im new to the dev lark and wondered if someone could point me in the right direction. I have the following (working!) app that lets users press a few buttons instead of typing console commands (please do not be too critical of it, its my fir
-
Precompilation of JSPs for default web application
Hello, Once in a while I need to redeploy my "Default" web application. I would like to have its all JSPs precompiled, so that it was immediatly available after redeployment. However, if I try to redeploy my web application (.war file) under, let's s
-
Media Encoder CS4 No Longer Runs
So, Media Encoder has just up and stopped launching for me. I have tried uninstalling and reinstalling, even deleting the folder it was installed in and replacing it with a backup. This is the error infor that Windows 7 gives me: Problem Event Name
-
HT4061 How can I get out of this situation? I am out of ideas and DESPARATE
I tried to update my iPhone 4 with the latest update iOS 7.1 or whatever it's called and it wants me to restore my phone. Well it didn't ****ing tell me that before I downloaded the mother****er and I don't have my phone prepared. Basically I NEED th
-
ADF table - problem with scroll bar
Hi all, I am using Jdev 11.1.1.0.1. I have a Read only View object that retuurns more than 2 million records. When i add this VO to the jspx page as an ADF read only table, scrollbars are not applied. Here is the page layout. <f:view> <af:document> <