Doubt on Sub routines
Hi friends,
I am using perform statement like
perfrom get_data using gi_data changing gi_output.
in the form of get_data i need to change gi_data but while coming out of form i need the gi_data to have the same value as i had before.
Is using is not like Call By value??
but now even if i pass through using the value is getting changed when it come out of form..
is there any ways to implement this please help me ......
Hi Gokul,
You can use the PERFORM as it is.
In the FORM, you can declare a LOCAL Internal table of type GI_DATA and assign the values of GI_DATA that you get in USING parameter to the local Intertnal table.
FORM GET_DATA USING GI_DATA
CHANGING GI_OUTPUT.
data: l_i_data type gi_data.
l_i_data[] = gi_data[].
Do what ever changes you want to do with l_i_data which is replica of gi_data, with out changing the original internal table.
ENDFORM.
<b>Reward points for informative answers.</b>
Best Regards,
Ram.
Similar Messages
-
Select statement in a sub routine(For Sapscript)
Hi,
M unable to write select statement for my reqirement in Sap-script in Sub routine.
My requirement is 1)"Your correspondent for quality" in main window of my form.
For dis rule is as below
"Get the 'changed by' value resord in table QCPR field AENDERER.For the same value found in tabe USR21 fiels BNAME,pick up the PERSUNUM value.For dis PERSUNUM value, found in ADRP feild NAME_TEXT the value for "Your Correspondent for Quality".
2) For this PERSUNUM value found in ADCP-TEL_NUMBER the vakue for "Ph".
3)For this PERSUNUM value found in ADCP-FAX_NUMBER the vakue for "FAX".
4For this PERSUNUM value found in ADR6-SMTP_ADDR the vakue for "EMAIL".
Please help me out it's urgent for me.I wil b waiting 4 ur reply.READ TABLE in_par WITH KEY 'QCPR-AENDERER'.
CHECK sy-subrc = 0.
MOVE in_par-value TO V_aenderer
. READ TABLE in_par WITH KEY 'USR21-BNAME.
CHECK sy-subrc = 0.
MOVE in_par-value TO V_bname
SELECT SINGLE persnumber addrnumber
INTO wa_usr21-persnumber wa_usr21-addrnumber
FROM usr21
WHERE bname = V_bname
and <b>check field for this</b> = V_aenderer.
CHECK sy-subrc = 0.
SELECT SINGLE tel_number fax_number
INTO adcp-tel_number adcp-fax_number
FROM adcp
WHERE addrnumber = usr21-addrnumber
AND persnumber = usr21-persnumber.
CHECK sy-subrc = 0.
READ TABLE out_par WITH KEY 'ADCP-TEL_NUMBER'.
CHECK sy-subrc = 0.
out_par-value = adcp-tel_number.
MODIFY out_par INDEX sy-tabix.
READ TABLE out_par WITH KEY 'ADCP-FAX_NUMBER'.
CHECK sy-subrc = 0.
out_par-value = adcp-fax_number.
MODIFY out_par INDEX sy-tabix.
SELECT SINGLE smtp_addr
INTO adr6-smtp_addr
FROM adr6
WHERE addrnumber = usr21-addrnumber
AND persnumber = usr21-persnumber.
READ TABLE out_par WITH KEY 'ADR6-SMTP_ADDR'.
CHECK sy-subrc = 0.
out_par-value = adr6-smtp_addr.
MODIFY out_par INDEX sy-tabix.
Regards -
How to on Debugging Mode for T-Code F110 from Script in Sub routine Pool Pr
Hi Every one....
I have done SAP-Script for Payment Vocher for T-code F110 ..I have a Sub Routine Program where I have few Form statements which is called by SAP - Script using Perform Statements, But my problem is when I set a break point in Sub Routine pool program, the out put is issuing with out Debugger ...
Could any one plz suggest me wht to do???
Help ful answers will be rewarded....
Regards,
sgHi,
First see if the 'Perform' statement is getting triggered in Script. To put a breakpoint in any script ( even if you do not know the form name, that is the best part ) is se38---->RSTXDBUG --->F8 & execute your pgm/Transaction. The control will wait in the form-debugger.
I hope this helps,
Regards
Raju Chitale -
Doubt on Start Routines.
Hi BW Experts,
I have a doubt on writing routines.I have enchaced the fields Network and WBS Element along with the data source 0FI_AP_4.And in BW side, I am getting data for Network and WBS Element.My requirement is to display the records which is having network or WBS Element.In reporting, I am not getting data if i exclude with Unassigned values for Network and WBS Element. So I decided to write routines in Transformations.
If /BIC/0NETWORK NE EMPTY OR /BIC/0WBS_ELEMNT NE EMPTY
Then
Load the data to 0FIAP_O03 (ODS)
I dont know how to write this logic in the form of ABAP Coding.
Please help on this Issue.
Thanks,
Jelina.
Edited by: Jelina on Apr 23, 2008 9:01 AMThanks for everybody..
As per karthik suggestion, now i am not getting the error.
I have added this one line Coding in the End Routine.
DELETE RESULT_PACKAGE where NETWORK EQ '' OR WBS_ELEMT EQ ''
While loading the data from datasource to ODS through DTP, none of the records are loaded to ODS.It is showing 0 records in New data table. I hope the coding is correct. And also 20 records is having the value for Network and WBS element.Herwith i have attached the full coding also. Please find the attached Code and provide me the solution Thanks in advance.
End Routine Code :
PROGRAM trans_routine.
CLASS routine DEFINITION
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
Available information: Refer to methods of
interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
PRIVATE SECTION.
TYPE-POOLS: rsd, rstr.
*Rule specific types
TYPES:
BEGIN OF tys_TG_1,
*Field: RECORD Data record number.
RECORD TYPE RSARECORD,
*InfoObject: 0COMP_CODE Company code.
COMP_CODE TYPE /BI0/OICOMP_CODE,
*InfoObject: 0CREDITOR Account number of supplier/vendor.
CREDITOR TYPE /BI0/OICREDITOR,
*InfoObject: 0FISCYEAR Fiscal year.
FISCYEAR TYPE /BI0/OIFISCYEAR,
*InfoObject: 0FISCPER Fiscal year / period.
FISCPER TYPE /BI0/OIFISCPER,
*InfoObject: 0FISCVARNT Fiscal year variant.
FISCVARNT TYPE /BI0/OIFISCVARNT,
*InfoObject: 0FISCPER3 Posting period.
FISCPER3 TYPE /BI0/OIFISCPER3,
*InfoObject: 0NETWORK Network.
NETWORK TYPE /BI0/OINETWORK,
*InfoObject: 0SUBNETWORK Subnetwork number.
SUBNETWORK TYPE /BI0/OISUBNETWORK,
*InfoObject: 0WBS_ELEMT Work Breakdown Structure Element (WBS Elem
*ent).
WBS_ELEMT TYPE /BI0/OIWBS_ELEMT,
*InfoObject: 0AC_DOC_NO Accounting document number.
AC_DOC_NO TYPE /BI0/OIAC_DOC_NO,
*InfoObject: 0ITEM_NUM Number of line item within accounting docum
*ent.
ITEM_NUM TYPE /BI0/OIITEM_NUM,
*InfoObject: 0FI_DSBITEM Due Date Item Number.
FI_DSBITEM TYPE /BI0/OIFI_DSBITEM,
*InfoObject: 0DCINDIC Debit/credit indicator.
DCINDIC TYPE /BI0/OIDCINDIC,
*InfoObject: 0FI_DOCSTAT Item Status.
FI_DOCSTAT TYPE /BI0/OIFI_DOCSTAT,
*InfoObject: 0C_CTR_AREA Credit Control Area.
C_CTR_AREA TYPE /BI0/OIC_CTR_AREA,
*InfoObject: 0DUNN_AREA Dunning area.
DUNN_AREA TYPE /BI0/OIDUNN_AREA,
InfoObject: 0ACCT_TYPE Account type.
ACCT_TYPE TYPE /BI0/OIACCT_TYPE,
InfoObject: 0SP_GL_IND Special G/L indicator.
SP_GL_IND TYPE /BI0/OISP_GL_IND,
InfoObject: 0AC_DOC_TYP Document type.
AC_DOC_TYP TYPE /BI0/OIAC_DOC_TYP,
InfoObject: 0POST_KEY Posting key.
POST_KEY TYPE /BI0/OIPOST_KEY,
InfoObject: 0VALUE_LC Amount in local currency.
VALUE_LC TYPE /BI0/OIVALUE_LC,
InfoObject: 0DOC_DATE Document Date.
DOC_DATE TYPE /BI0/OIDOC_DATE,
InfoObject: 0PSTNG_DATE Posting date in the document.
PSTNG_DATE TYPE /BI0/OIPSTNG_DATE,
InfoObject: 0CREATEDON Date on which the record was created.
CREATEDON TYPE /BI0/OICREATEDON,
InfoObject: 0CLEAR_DATE Clearing date.
CLEAR_DATE TYPE /BI0/OICLEAR_DATE,
InfoObject: 0LAST_DUNN Date of last dunning notice.
LAST_DUNN TYPE /BI0/OILAST_DUNN,
InfoObject: 0NETDUEDATE Due date for net payment.
NETDUEDATE TYPE /BI0/OINETDUEDATE,
InfoObject: 0DSCT_DATE1 Due date for cash discount 1.
DSCT_DATE1 TYPE /BI0/OIDSCT_DATE1,
InfoObject: 0DSCT_DATE2 Due date for cash discount 2.
DSCT_DATE2 TYPE /BI0/OIDSCT_DATE2,
InfoObject: 0DSCT_DAYS1 Days for Cash Discount 1.
DSCT_DAYS1 TYPE /BI0/OIDSCT_DAYS1,
InfoObject: 0DSCT_DAYS2 Days for Second Cash Discount.
DSCT_DAYS2 TYPE /BI0/OIDSCT_DAYS2,
InfoObject: 0NETTERMS Deadline for Net Conditions.
NETTERMS TYPE /BI0/OINETTERMS,
InfoObject: 0DSCT_PCT1 Percentage for Cash Discount 1.
DSCT_PCT1 TYPE /BI0/OIDSCT_PCT1,
InfoObject: 0DSCT_PCT2 Percentage for second cash discount.
DSCT_PCT2 TYPE /BI0/OIDSCT_PCT2,
InfoObject: 0PYMT_METH Payment method.
PYMT_METH TYPE /BI0/OIPYMT_METH,
InfoObject: 0PMNTTRMS Terms of Payment Key.
PMNTTRMS TYPE /BI0/OIPMNTTRMS,
InfoObject: 0PMNT_BLOCK Payment block key.
PMNT_BLOCK TYPE /BI0/OIPMNT_BLOCK,
InfoObject: 0REASON_CDE Reason code for payments.
REASON_CDE TYPE /BI0/OIREASON_CDE,
InfoObject: 0BLINE_DATE Baseline Date For Due Date Calculation.
BLINE_DATE TYPE /BI0/OIBLINE_DATE,
InfoObject: 0DUNN_BLOCK Dunning block.
DUNN_BLOCK TYPE /BI0/OIDUNN_BLOCK,
InfoObject: 0DUNN_KEY Dunning key.
DUNN_KEY TYPE /BI0/OIDUNN_KEY,
InfoObject: 0DEBIT_LC Debit amount in local currency.
DEBIT_LC TYPE /BI0/OIDEBIT_LC,
InfoObject: 0LOC_CURRCY Local currency.
LOC_CURRCY TYPE /BI0/OILOC_CURRCY,
InfoObject: 0CREDIT_LC Credit amount in local currency.
CREDIT_LC TYPE /BI0/OICREDIT_LC,
InfoObject: 0DEB_CRE_LC Amount in Local Currency with +/- Signs.
DEB_CRE_LC TYPE /BI0/OIDEB_CRE_LC,
InfoObject: 0DSC_AMT_LC Cash discount amount in local currency.
DSC_AMT_LC TYPE /BI0/OIDSC_AMT_LC,
InfoObject: 0DEBIT_DC Debit amount in foreign currency.
DEBIT_DC TYPE /BI0/OIDEBIT_DC,
InfoObject: 0DOC_CURRCY Document currency.
DOC_CURRCY TYPE /BI0/OIDOC_CURRCY,
InfoObject: 0CREDIT_DC Credit amount in foreign currency.
CREDIT_DC TYPE /BI0/OICREDIT_DC,
InfoObject: 0DEB_CRE_DC Foreign currency amount with signs (+/-).
DEB_CRE_DC TYPE /BI0/OIDEB_CRE_DC,
InfoObject: 0DISC_BASE Amount eligible for cash discount in docum
*ent currency.
DISC_BASE TYPE /BI0/OIDISC_BASE,
InfoObject: 0AMOUNT Amount.
AMOUNT TYPE /BI0/OIAMOUNT,
InfoObject: 0CURRENCY Currency Key.
CURRENCY TYPE /BI0/OICURRENCY,
InfoObject: 0DSC_AMT_DC Cash discount amount in document currency
DSC_AMT_DC TYPE /BI0/OIDSC_AMT_DC,
InfoObject: 0DUNN_LEVEL Dunning level.
DUNN_LEVEL TYPE /BI0/OIDUNN_LEVEL,
InfoObject: 0CHRT_ACCTS Chart of accounts.
CHRT_ACCTS TYPE /BI0/OICHRT_ACCTS,
InfoObject: 0GL_ACCOUNT G/L Account.
GL_ACCOUNT TYPE /BI0/OIGL_ACCOUNT,
InfoObject: 0RC_ACCOUNT Reconciliation Account.
RC_ACCOUNT TYPE /BI0/OIRC_ACCOUNT,
InfoObject: 0FI_SUBSID Account Number of the Branch.
FI_SUBSID TYPE /BI0/OIFI_SUBSID,
InfoObject: 0CLR_DOC_NO Clearing Document Number.
CLR_DOC_NO TYPE /BI0/OICLR_DOC_NO,
InfoObject: 0REF_DOC_NO Reference document number.
REF_DOC_NO TYPE /BI0/OIREF_DOC_NO,
InfoObject: 0INV_DOC_NO Invoice Number.
INV_DOC_NO TYPE /BI0/OIINV_DOC_NO,
InfoObject: 0INV_ITEM Invoice Item.
INV_ITEM TYPE /BI0/OIINV_ITEM,
InfoObject: 0INV_YEAR Invoice Year.
INV_YEAR TYPE /BI0/OIINV_YEAR,
InfoObject: 0DOC_NUMBER Sales document.
DOC_NUMBER TYPE /BI0/OIDOC_NUMBER,
InfoObject: 0REF_KEY1 Reference Key 1.
REF_KEY1 TYPE /BI0/OIREF_KEY1,
InfoObject: 0REF_KEY2 Reference Key 2.
REF_KEY2 TYPE /BI0/OIREF_KEY2,
InfoObject: 0REF_KEY3 Reference Key 3.
REF_KEY3 TYPE /BI0/OIREF_KEY3,
InfoObject: 0FI_XARCH Indicator: Original Document Archived.
FI_XARCH TYPE /BI0/OIFI_XARCH,
InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
RECORDMODE TYPE RODMUPDMOD,
InfoObject: 0POSTXT Item Text.
POSTXT TYPE /BI0/OIPOSTXT,
InfoObject: 0COUNTRY Country key.
COUNTRY TYPE /BI0/OICOUNTRY,
InfoObject: 0SP_GL_TT Special G/L Transaction Type.
SP_GL_TT TYPE /BI0/OISP_GL_TT,
InfoObject: 0ALLOC_NMBR Allocation Number.
ALLOC_NMBR TYPE /BI0/OIALLOC_NMBR,
END OF tys_TG_1.
TYPES:
tyt_TG_1 TYPE STANDARD TABLE OF tys_TG_1
WITH NON-UNIQUE DEFAULT KEY.
$$ begin of global - insert your declaration only below this line -
... "insert your code here
$$ end of global - insert your declaration only before this line -
METHODS
end_routine
IMPORTING
request type rsrequest
datapackid type rsdatapid
EXPORTING
monitor type rstr_ty_t_monitors
CHANGING
RESULT_PACKAGE type tyt_TG_1
RAISING
cx_rsrout_abort.
METHODS
inverse_end_routine
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
i_r_selset_outbound TYPE REF TO cl_rsmds_set
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO cl_rsmds_universe
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO cl_rsmds_set
c_exact TYPE rs_bool.
ENDCLASS. "routine DEFINITION
$$ begin of 2nd part global - insert your code only below this line *
... "insert your code here
$$ end of 2nd part global - insert your code only before this line *
CLASS routine IMPLEMENTATION
CLASS lcl_transform IMPLEMENTATION.
Method end_routine
Calculation of result package via end routine
Note: Update of target fields depends on rule assignment in
transformation editor. Only fields that have a rule assigned,
are updated to the data target.
<-> result package
METHOD end_routine.
*=== Segments ===
FIELD-SYMBOLS:
<RESULT_FIELDS> TYPE tys_TG_1.
DATA:
MONITOR_REC TYPE rstmonitor.
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*DELETE RESULTPACKAGE where NETWORK EQ '' OR WBS_ELEMT EQ ''*_
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
raise exception type CX_RSROUT_ABORT.
$$ end of routine - insert your code only before this line -
ENDMETHOD. "end_routine
Method inverse_end_routine
This subroutine needs to be implemented only for direct access
(for better performance) and for the Report/Report Interface
(drill through).
The inverse routine should transform a projection and
a selection for the target to a projection and a selection
for the source, respectively.
If the implementation remains empty all fields are filled and
all values are selected.
METHOD inverse_end_routine.
$$ begin of inverse routine - insert your code only below this line-
... "insert your code here
$$ end of inverse routine - insert your code only before this line -
ENDMETHOD. "inverse_end_routine
ENDCLASS. "routine IMPLEMENTATION -
How do we write the sub routines in smart forms?
1) How do we write the sub routines in smart forms?
2) What is the form interface in smart forms?
3) Write down the path for writing for select queries in smart forms?
4) How do we put dynamic page break in smart forms?
5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
6) What is the name of function module used to calling smart forms?
1) What is the functionality of function module controal_form?
2) How do we print the system date in this format 15th Jan 2008 on scripts?
3) What r the various print modes available in scripts?
4) What is the tcode for text element?
5) How do we draw horizontal line in scripts?
6) How can we suppress the leading zeros for a field in scripts?
7) In which system field is used to print current no page in scripts?
Which f.m is used to reads text in sap scripts1) How do we write the sub routines in smart forms?
after opening form see global definitions
click on that there one tab called form routines inthat you can write subroutines logic.
You can call in program lines .
2) What is the form interface in smart forms?
It is an interface between program and form .
like function module we provide import,export,tables,exceptions
Based on import and export parameters form will display for us.
3) Write down the path for writing for select queries in smart forms?
On window give right click in that command->programlines
you can write all select statements.
4) How do we put dynamic page break in smart forms?
you can define break point using break-point<>. syntax.
5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
SFSY-PAGE
SFSY-JOBPAGES
6) What is the name of function module used to calling smart forms?
SSF_FUNCTION_MODULE_NAME
=================
1) What is the functionality of function module control_form?
This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
COMMAND =
EXCEPTIONS
UNOPENED = 1
OTHERS = 3
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
2) How do we print the system date in this format 15th Jan 2008 on scripts?
Use SET DATE MASK to change format of date display.
3) What r the various print modes available in scripts?
4) What is the tcode for text element?
se91
5) How do we draw horizontal line in scripts?
&ULINE&
6) How can we suppress the leading zeros for a field in scripts?
&it_vbak-vbeln(Z)&
7) In which system field is used to print current no page in scripts?
&SYST-PAGE& of &SYST-FORMPAGES&
Which f.m is used to reads text in sap scripts
READ_TEXT functiomodule.
Reward points -
Dynamic TABLE parameter in Sub routine call
Hi,
Is it possible to have a dynamic TABLE parameter in a sub-routine call? The structure of the internal table will be different during different calls to the sub-routine.
I have a subroutine which has the FM "HR_INFOTYPE_OPERATION" to update the infotype data for an Applicant. Now i want to call this subroutine for every Infotype update. So every time the structure of the internal table to be passed will vary depending on Infotype ( eg P0002 for Infotype 0002, p0006 for infotype 0006).
Any pointers will be appreciated.
Thanks in advance.Hi Navin,
yes, why not.
just use a generic type parameter, i.e.
FORM process USING IT_00x type table IV_type typc.
It depend what yout FORM shall do. If you pass the types name, you can dynamically assign to a field-symbol of the respective type.
Regards,
Clemens -
How do i make this a sub routine
I have a little script to drill down folders and add comments to every folder and ever file inside the parent folder. It works perfectly well when run but itself. This was based heavily on the script found by NovaScotian here http://discussions.apple.com/thread.jspa?messageID=2182916�
I basically want to make this script into a sub routine, and i have tried various methods and havent been able to make it work.
global the_comments
global each_item
global pete
global ddp
global ddp2
set ddp to {}
set ddp2 to {}
set theLetter to "s"
set newDroppedFiles to choose folder with multiple selections allowed
to drilldown(afolder)
tell application "Finder"
set file_list to files of a_folder
set folder_list to folders of a_folder
end tell
repeat with i in file_list
processDrilledDownFile(i)
tell application "Finder"
set comment of pete to text of the_comments
end tell
end repeat
repeat with i in folder_list
copy i to end of ddp2
drill_down(i)
end repeat
end drill_down
on processDrilledDownFile(a_file)
copy a_file to end of ddp
end processDrilledDownFile
set the_comments to (do shell script "/usr/bin/defaults read com.Rich.move " & theLetter & "Text")
repeat with each_item in newDroppedFiles
set pete to each_item
tell application "Finder"
set comment of each_item to text of the_comments
end tell
drill_down(pete)
end repeat
repeat with each_item in ddp
tell application "Finder"
set comment of each_item to text of the_comments
end tell
end repeat
repeat with each_item in ddp2
tell application "Finder"
set comment of each_item to text of the_comments
end tell
end repeat
regards
RichYour script already includes several subroutines, so the trick is separating those out first.
Essentially your script consists of three elements - global declarations, your own subroutines and a run handler. Since there's no explicit 'on run', everything that's not inside a subroutine becomes the run handler.
Therefore what you should do is strip out all the code that's not a global declaration or an existing handler and just wrap that in a new 'on subroutinename()... end subroutinename' block.
For sanity's sake I'd also add a specific run handler to bind it all together.
This means you'll end up with something like:
<pre class=command>global the_comments
global each_item
global pete
global ddp
global ddp2
on run
my myNiftySubroutine()
end run
to drilldown(afolder)
tell application "Finder"
set file_list to files of a_folder
set folder_list to folders of a_folder
end tell
repeat with i in file_list
processDrilledDownFile(i)
tell application "Finder"
set comment of pete to text of the_comments
end tell
end repeat
repeat with i in folder_list
copy i to end of ddp2
drill_down(i)
end repeat
end drill_down
on processDrilledDownFile(a_file)
copy a_file to end of ddp
end processDrilledDownFile
on myNiftySubroutine()
set ddp to {}
set ddp2 to {}
set theLetter to "s"
set newDroppedFiles to choose folder with multiple selections allowed
set the_comments to (do shell script "/usr/bin/defaults read com.Rich.move " & theLetter & "Text")
repeat with each_item in newDroppedFiles
set pete to each_item
tell application "Finder"
set comment of each_item to text of the_comments
end tell
drill_down(pete)
end repeat
repeat with each_item in ddp
tell application "Finder"
set comment of each_item to text of the_comments
end tell
end repeat
repeat with each_item in ddp2
tell application "Finder"
set comment of each_item to text of the_comments
end tell
end repeat
end myNiftySubroutine</pre>
There's just one other observation - most of the globals are not actually needed since you can just pass them as parameters to the subroutines.
I'm also not sure what the purpose of the script is - the upshot seems to be that you're setting the comment of items in the Finder, however, since you:
<pre class=command> set comment of pete to text of the_comments</pre>
and pete is a global pointing to the folder you're processing, surely this sets the comment of the folder x times, where x is the number of files in the folder - in other words if there are 100 files in the folder, you set the comment of the folder 100 times and don't touch the files themselves. Is that what you intend? -
Passing parametrs to Sub routines
Hi all,
Please tell me how to pass the Parameters as message number and message id for an SUB ROUTINE.If possible please give me the sample code.
Regards
Ajaydeclare
data : message_nm type sy-msgno,
sys_id type sy-repid.
simply write rthe oerform AS
perform sample_form using message_nm
sys_id
then in the form.
form sample_form using message_nm type sy-msgno
sys_id type sy-repid .
endform.
reward points if useful...
Edited by: Rudra Prasanna Mohapatra on Jun 25, 2008 1:41 PM -
Include or sub-routine in user-exit
Hi all,
i want to put a sub-routine in my customer user-exit (CMOD).but i can not put the subroutine.
can i put a subroutine or include statement in a user exit?
correct answers will be rewarded.
Thanks
pabiYou can make subroutine calls inside a User exit, only if the exit is part of a function pool. All the subroutines can be placed in an include in the function pool & can be called with a Perform Statement from the User Exit.
~Suresh -
How do we define a sub-routine in a subroutine pool
How do we define a sub-routine in a subroutine pool and how do we call the same in an executable program
Hi
Go to SE38.Create a program and in the program type select Subroutine pool.Inside this u can code for teh various subroutines or forms.
For calling these forms these forms in ur main program refer below link:
<u>http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm</u>
Sample code:
Below is the subroutine pool used in the creation of the SAP Script:
Program Name : Z689_SUBROUTINE
Date : 03/28/2007
Author : Sayee Manojnah Kasala
Description : This is the subroutine used for SAP Script,
Z689_SAPSCRIPT.It fetches customer details like
customer name & place
PROGRAM Z689_SUBROUTINE.
Form GET_LAND1
Fetches the country key
*& Form get_land1
text
-->INTABLE text
-->OUTTABLE text
FORM get_land1 TABLES intable STRUCTURE itcsy
outtable STRUCTURE itcsy.
DATA: v_kunnr LIKE kna1-kunnr,
v_land1 LIKE kna1-land1,
v_name1 LIKE kna1-name1.
READ TABLE intable INDEX 1.
v_kunnr = intable-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kunnr
IMPORTING
output = v_kunnr.
IF sy-subrc = 0.
SELECT SINGLE land1
FROM kna1
INTO v_land1
WHERE kunnr = v_kunnr.
IF sy-subrc = 0.
READ TABLE outtable INDEX 1.
outtable-value = v_land1.
MODIFY outtable INDEX 1.
ENDIF.
SELECT SINGLE name1
FROM kna1
INTO v_name1
WHERE kunnr = v_kunnr.
IF sy-subrc = 0.
READ TABLE outtable INDEX 2.
outtable-value = v_name1.
MODIFY outtable INDEX 2.
ENDIF.
ENDIF.
CLEAR: intable,outtable.
ENDFORM. "get_land1
Form GET_LANDX
Fetches the Country Name
*& Form get_landx
text
-->INTABLE text
-->OUTTABLE text
FORM get_landx TABLES intable STRUCTURE itcsy
outtable STRUCTURE itcsy.
DATA: v_land1 LIKE kna1-land1,
v_landx LIKE t005t-landx.
READ TABLE intable INDEX 1.
v_land1 = intable-value.
IF sy-subrc = 0.
SELECT SINGLE landx
FROM t005t
INTO v_landx
WHERE land1 = v_land1 AND spras = 'E'.
IF sy-subrc = 0.
READ TABLE outtable INDEX 1.
outtable-value = v_landx.
MODIFY outtable INDEX 1.
ENDIF.
ENDIF.
CLEAR: intable,outtable.
ENDFORM. "get_landx
It can be called as follows:
PERFORM GET_LANDX IN PROGRAM Z689_SUBROUTINE
USING &V_LAND1&
CHANGING&V_LANDX&
ENDPERFORM.
Reward points if found useful.
Thanks
Vasudha
Message was edited by:
Vasudha L -
Urgent!!!!Related To SUB-ROUTINES
Hi All,
I have 2 subroutines.My problem is that if a particular sub-routine is terminated in middle for any reason my second sub-routine should not get called.How can i know that?Please answer my question as soon as possible.
Useful answers will be rewarded with points.
Regards,
Chaitanya.
Message was edited by:
LEELA KRISHNA SAI CHAITANYAHi leela,
you can use one global variable for this as flag.
ex:
data flag type c.
perform sub1.
if flag = 'X'.
perform sub2.
endif.
form sub1.
if (condition yes).
flag = 'X'.
endif.
endform.
form sub2.
endform.
this will work well -
Smart forms not displaying result from sub routine
I am working on a smart form and need to display the description of the fabric code. Under Form Routines, I create a sub routine
FORM fcc_values USING gv_fabrictext.
which is supposed to store the description in gv_fabrictext. GV_FABRICTEXT has been declared in global data as char64. Then I call prior to displaying my table as
perform fcc_values using gv_fabrictext.
And then insert the field &gv_fabrictext& in cell but this does not display any result
I know for sure that this sub routine works as I have tested it separately as a test program. Any ideas?1. put break point at ssf_function madulename and check field value.
or
2 fm_name export parameter ur not mentioned
or
3 global variable not defined properly
go through above. still if u didnt get
need program where the problem to find.
Message was edited by:
Deepa KN -
how can u call a sub-routine from other programmes?
Hi,
Start of Content Area
Naming Subroutines Locate the document in its SAP Library structure
With the PERFORM statement, you can call subroutines which are coded in the same ABAP program (internal calls), or subroutines which are coded in other ABAP programs (external calls).
You can also specify the name of the subroutine dynamically at runtime, and call subroutines from a list.
Internal Subroutine Calls
To call a subroutine defined in the same program, you need only specify its name in the PERFORM statement:
PERFORM subr [USING p1 p2... ]
[CHANGING p1 p2... ].
The internal subroutine can access all of the global data of the calling program.
Example
REPORT demo_mod_tech_perform_int.
DATA: num1 TYPE i,
num2 TYPE i,
sum TYPE i.
num1 = 2. num2 = 4.
PERFORM addit.
num1 = 7. num2 = 11.
PERFORM addit.
FORM addit.
sum = num1 + num2.
PERFORM out.
ENDFORM.
FORM out.
WRITE: / 'Sum of', num1, 'and', num2, 'is', sum.
ENDFORM.
This produces the following output:
Sum of 2 and 4 is 6
Sum of 7 and 11 is 18
In this example the subroutines addit and out are defined at the end of the program. addit is called by the program and out is called by addit. The subroutines have access to the global fields num1, num2 und sum.
External Subroutine Calls
The principal function of subroutines is for modularizing and structuring local programs. However, subroutines can also be called externally from other ABAP programs. In an extreme case, you might have an ABAP program that contained nothing but subroutines. These programs cannot run on their own, but are used by other ABAP programs as pools of external subroutines.
However, if you want to make a function available throughout the system, you should use function modules instead of external subroutines. You create function modules in the ABAP Workbench using the Function Builder. They are stored in a central library, and have a defined release procedure.
You can encapsulate functions and data in the attributes and methods of classes in ABAP Objects. For any requirements that exceed pure functions, you can use global classes instead of external subroutines.
When you call a subroutine externally, you must know the name of the program in which it is defined:
PERFORM subr(prog) [USING p1 p2... ]
[CHANGING p1 p2... ] [IF FOUND].
You specify the program name prog statically. You can use the IF FOUND option to prevent a runtime error from occurring if the program progdoes not contain a subroutine subr. In this case, the system simply ignores the PERFORM statement.
When you call an external subroutine, the system loads the whole of the program containing the subroutine into the internal session of the calling program (if it has not already been loaded). In order to save memory space, you should keep the number of subroutines called in different programs to a minimum.
Example
Suppose a program contains the following subroutine:
REPORT formpool.
FORM header.
WRITE: / 'Program started by', sy-uname,
/ 'on host', sy-host,
'date:', sy-datum, 'time:', sy-uzeit.
ULINE.
ENDFORM.
The subroutine can then be called from another program as follows:
REPORT demo_mod_tech_perform_ext.
PERFORM header(demo_mod_tech_formpool_1) IF FOUND.
In this example, no data is passed between the calling program and the subroutine.
Specifying Subroutines Dynamically
You can specify the name of a subroutine and, in the case of external calls, the name of the program in which it occurs, dynamically as follows:
PERFORM (fsubr)[IN PROGRAM (fprog)][USING p1 p2... ]
[CHANGING p1 p2... ]
[IF FOUND].
The names of the subroutine and the external program are the contents of the fields fsubr und fprogrespectively. By using the option IF FOUND, you can prevent a runtime error from being triggered if no subroutine with the name fsubr is found. If you omit the parentheses, this variant of the PERFORMstatement behaves like the static variant.
Example
Assume a program contains the following subroutines:
PROGRAM formpool.
FORM sub1.
WRITE: / 'Subroutine 1'.
ENDFORM.
FORM sub2.
WRITE: / 'Subroutine 2'.
ENDFORM.
Dynamic Subroutine Specification:
PROGRAM form_test.
DATA: progname(8) TYPE c VALUE 'FORMPOOL',
subrname(8) TYPE c.
subrname = 'SUB1'.
PERFORM (subrname) IN PROGRAM (progname) IF FOUND.
SUBRNAME = 'SUB2'.
PERFORM (subrname) IN PROGRAM (progname) IF FOUND.
This produces the following output:
Subroutine 1
Subroutine 2
The character field progname contains the name of the program, in which the subroutines are contained. The names of the subroutines are assigned to the character field subrname.
Calling Subroutines from a List
You can call a subroutine from a list as follows:
PERFORM idx OF subr1 subr2 ... subrn.
The system calls the subroutine specified in the subroutine list in position idx. You can only use this variant of the PERFORMstatement for internal subroutine calls, and only for subroutines without a parameter interface. The field idx can be a variable or a literal.
Example
REPORT demo_mod_tech_perform_list.
DO 2 TIMES.
PERFORM sy-index OF sub1 sub2.
ENDDO.
FORM sub1.
WRITE / 'Subroutine 1'.
ENDFORM.
FORM sub2.
WRITE / 'Subroutine 2'.
ENDFORM.
This produces the following output:
Subroutine 1
Subroutine 2
Regards,
Chandru -
I have a doubt with the use of sub-queries. I am using a query like as below & it is giving me expected result:-
SELECT ISS.item_type_id,count(1) + (select sum(invoiced_qty) from ppbs_invoice_detail where
trunc(created_date) between '01-jul-05' and '04-jul-05' and item_type_id=ISS.item_type_id) qty
FROM ppbs_INV_SIM_SERIAL ISS
WHERE INSTR('ROAAIT',STATUS)>0
AND INSTR('NU0NU1NU2NU3SC0',CITY_CODE) =0
and ISS.item_type_id in ('SM17')
group by ISS.item_type_id --
I will re-write above query & i have been using queries like :-
SELECT ISS.item_type_id,count(1) qty
FROM ppbs_INV_SIM_SERIAL ISS
WHERE INSTR('ROAAIT',STATUS)>0
AND INSTR('NU0NU1NU2NU3SC0',CITY_CODE) =0
and ISS.item_type_id in ('SM17') and item_type_id in
(select item_type_id from ppbs_invoice_detail where
trunc(created_date) between '01-jul-05' and '04-jul-05' and item_type_id=ISS.item_type_id)
group by ISS.item_type_id
my doubt here is that the sub-query in the first query is coming before i use the table 'ppbs_inv_sim_serial ISS' whereas in the second query, the table use 'ppbs_inv_sim_serial ISS' is coming before the sub-query use. I have been using queries where table name is defined before the sub-query.
I hope, my question is clear. Please help in solving the doubt.
Regards.I don't see a problem with the table aliasing that you seem to doubt, but your first query won't run. I boiled the thing down to basics: SQL>create table t1 (one number, val_1 number );
Table created.
SQL>create table t2 (one number, val_2 number );
Table created.
SQL>insert into t1 values (1,1);
1 row created.
SQL>insert into t2 values (1,2);
1 row created.
SQL>select a.one, count(1) + ( select sum(val_2) from t2 where t2.one = a.one) qty
2 from t1 a
3 group by one;
select a.one, count(1) + ( select sum(val_2) from t2 where t2.one = a.one) qty
ERROR at line 1:
ORA-00979: not a GROUP BY expression
SQL>
SQL>select a.one, count(1) qty
2 from t1 a
3 where a.one in ( select one from t2 where one = a.one)
4 group by one;
ONE QTY
1 1It's superfluous to "where a.one in ( select.. where = a.one) but that's your code basically. I would just do "=" -
HOW DO I KEEP AN ARRAYLIST IN RANDOM ORDER AFTER EXITING THE SUB ROUTINE CONTAINING IT
PLEASE HELP!I am trying to go from VB4 which I loved to VB2010 which I find somewhat more challenging. I’ve searched the web for help and have adapted the following to my project. This code does
rotate randomly through every card in the deck and displays unique cards until all have been drawn. BUT I want to draw one card
only from the first “hat” of Boy’s names; then draw the second card from the second “hat” of Girl’s names and repeat this process until all cards in both decks have been drawn. How do I get the TextBox (OR any
MsgBox) to display JUST ONE unique random card at a time so I can exit that deck and go to the next deck?
On my form, I have two TextBoxes (to display the names (as drawn), two buttons (to re-load each deck once exhausted) and one command (&End)control (to end the process). I created two ArraysLists
(to hold the Boys names and Girls names separately) and two ArrayLists to hold the cards for the random decks when created in code.
I can
NOT get this code to draw random UNIQUE names once I exit the deck. I have tried to ReDim the deck; randomly pull a card from the second (temp) deck, etc
NOTHING seems to work.
WHY does my deck lose randomness once I exit it?
How can I fix it? I don’t understand this. Below is the code for the "hat" with the 10 girl's names.
Also, when I don't loop through all the cards, I usually get "An Out of Index exception was not handled" error. Hope someone can help me with this problem. It seems like this should
be easy BUT I'm baffled. Thank you for any help.
Imports System.Collections.Generic
Public Class Form1
Dim Count As Integer
Dim Rcard As New ArrayList
Dim Dcard As New ArrayList
Dim NewRDeck As New ArrayList
Dim NewDDeck As New ArrayList
Dim temp_Rnum As Integer
Dim temp_Dnum As Integer
Dim MyRand As New Random()
Public Sub Rcards_Click(sender As Object, e As System.EventArgs) Handles Rcards.Click
While Rcard.Count > 0
Dim temp_Rnum As Integer = Int(MyRand.Next(Rcard.Count))
NewRDeck(temp_Rnum) = Rcard(temp_Rnum)
Rem Check that the ArrayLists work correctly and display properly
MsgBox(Rcard(temp_Rnum), , "New random card selected is: ")
Console.WriteLine(Rcard(temp_Rnum))
Rcard.Text = (Rcard(temp_Rnum))
REM Now remove the Rcard with the random number generated so it can't be drawn again
Rcard.RemoveAt(temp_Rnum)
End While
REM When all 10 cards have been picked, alert player to re-load deck if desired.
MsgBox("No new cards left in deck; please Re-Load the cards. Thank you.")
EndSub
End ClassHi Acamar,
Thank you for such a fast response. Sorry if my text wasn't clear. I'm really struggling with creating unique random elements in Collections in VB2010 and feel I understand ArrayLists better than some of the other Collection types.The code works perfectly
and generates unique random cards until the original deck is exhausted. Then it prompts the user to re-load the original deck so it can be reused if needed. But I need to draw one card only and exit the deck. Then when I click on the TextBox again, I want
that deck to be in the same random order - just minus any cards I have already drawn and thrown away. Thanks again for your help.
Here's the rest of the code for just the girl's "hats" of names, if it helps:
Private Sub btnShuffleRCards_Click(sender
As System.Object, e
As System.EventArgs)
Handles btnShuffleRCards.Click
Dim j As
Integer
For j = 1 To 10
NewRDeck.Add(j)
Next j
Randomize()
REM Create original Deck with names for the girls.
Rcard.Add("1 HELEN”)
Rcard.Add("2 OLIVIA")
Rcard.Add("3 <st1:city w:st="on"><st1:place w:st="on">ALICE</st1:place></st1:city>")
Rcard.Add("4 VALERIE")
Rcard.Add("5 DONNA")
Rcard.Add("6 ZELDA")
Rcard.Add("7 MARGARIE")
Rcard.Add("8 <st1:city w:st="on"><st1:place w:st="on">NANCY</st1:place></st1:city>")
Rcard.Add("9 WANDA")
Rcard.Add("10 IRENE")
End Sub
Maybe you are looking for
-
Does moving sites using Content and Structure cause issues in SQL content db's?
I would like to be able to use "manage content and structure" to move sub-sites within a site collection (SharePoint 2010). For example I have a site that is right under my top level site and I would like to move it to be the child site of one of its
-
Two time machine questions i cannot find an answer for ...
1) i use a 1 TB time capsule to back up my macbook. can i use this back up to restore to a windows computer in case of a macbook crash ? ( no plans to shift back to windows, but just need to know. ) 2) i also separately back up my 395 GB music collec
-
InDesign CS6 crashing constantly - why?
Since updating to Mavericks, my daily crashes whilst using InDesign CS6 (on an iMac) have escalated to a ridiculous degree and it doesn't seem to matter what I'm doing at the time. Have Googled this issue again and again, tried a plethora of suggeste
-
Oracle forms/reports 6i runtime installation files
I need oracle forms/reports 6i runtime installation files. Please help me to download runtime installation exe files. Thanks in advance.
-
SAP_WAPI_DECISION_COMPLETE : Processing can be rejected option
In my workflow I am using a decision task which sometimes has to be approved in the background. This decision task has two outcomes Approve and Reject. I am also using the option "PROCESSING CAN BE REJECTED" under details tab of the approval step in