2005 Aug 03 11:58 AM
Hi,
I'm trying to modularise my code. I have a function which call some forms. But when I try and compile it, I keep getting Syntax errors, and I'm not sure how to get round them. The code is shown below.
FUNCTION z_fs_allocated_payment_clear.
DATA BEGIN OF bdcdtab OCCURS 1.
INCLUDE STRUCTURE bdcdata.
DATA END OF bdcdtab.
DATA BEGIN OF messtab OCCURS 10.
INCLUDE STRUCTURE bdcmsgcoll.
DATA END OF messtab.
DATA BEGIN OF ybsid OCCURS 1.
INCLUDE STRUCTURE bsid.
DATA END OF ybsid.
PERFORM ybsid_fill ybsid.
PERFORM bdcdtab_fill bdcdtab.
PERFORM call_transaction.
endfunction.
FORM bdcdtab_fill using bdcdtab.
CLEAR bdcdtab.
REFRESH bdcdtab.
*-- Felder des Startdynpros der Ausgleichstransaktion füllen------
bdcdtab-program = 'SAPMF05A'.
bdcdtab-dynpro = '0131'.
bdcdtab-dynbegin = 'X'.
bdcdtab-fnam = ' '.
bdcdtab-fval = ' '.
APPEND bdcdtab.
.
.
.
Endform.
FORM ybsid_fill changing ybsid.
ybsid-mandt = '800'.
ybsid-bukrs = '2000'.
ybsid-kunnr = '0000300730'.
ybsid-umsks =
ybsid-umskz =
ybsid-augdt =
ybsid-augbl =
ybsid-zuonr = 'V31'.
ybsid-gjahr = '2005'.
.
.
.
endform.
I've tried using "changing, using , tables" to no avail.
Thanks
2005 Aug 03 12:23 PM
hi sims, its not clear which all parameters you are using, so please do copy your total source code from the top till the bottom. then we can repeat the same fucntion module at our end too and can give you an appropriate solution,
but as of now we are unable to know which bare you import paranmters or export parameters.
thanks & regards,
venugopal
2005 Aug 03 12:01 PM
Hi Sims,
Can you tell what is the syntax error which you are getting in your code.
/Manik
2005 Aug 03 12:03 PM
Hi,
If a subroutine has a parameter interface, you must supply values to all of the formal parameters in its interface when you call it. You list the actual parameters after the USING or CHANGING addition in the PERFORM statement.
When you pass the values, the sequence of the actual parameters in the PERFORM statement is crucial. The value of the first actual parameter in the list is passed to the first formal parameter, the second to the second, and so on. The additions USING and CHANGING have exactly the same meaning. You only need to use one or the other. However, for documentary reasons, it is a good idea to divide the parameters in the same way in which they occur in the interface definition.
Actual parameters can be any data objects or field symbols of the calling program whose technical attributes are compatible with the type specified for the corresponding formal parameter. When you specify the actual parameters, note that any that you pass by reference to a formal parameter, and any that you pass by value to an output parameter, can be changed by the subroutine. You should therefore ensure that only data objects that you want to be changed appear in the corresponding position of the actual parameter list.
If a subroutine contains TABLES parameters in its interface, you must specify them in a TABLES addition of the PERFORM statement before the USING and CHANGING parameters. TABLES parameters are only supported to ensure compatibility with earlier releases, and should no longer be used.
You can specify actual parameters with variable offset and length specifications. Offset specifications for actual parameters function as offset specifications for field symbols. You can select memory areas that lie outside the boundaries of the specified actual parameter.
PROGRAM FORM_TEST.
DATA: A1 TYPE P DECIMALS 3,
A2 TYPE I,
A3 TYPE D,
A4 TYPE SPFLI-CARRID,
A5 TYPE C.
...
PERFORM SUBR USING A1 A2 A3 A4 A5.
...
PERFORM SUBR CHANGING A1 A2 A3 A4 A5.
...
PERFORM SUBR USING A1 A2 A3
CHANGING A4 A5.
...
FORM SUBR USING
VALUE(F1) TYPE P
VALUE(F2) TYPE I
F3 LIKE A3
CHANGING
VALUE(F4) TYPE SPFLI-CARRID
F5.
...
ENDFORM.
2005 Aug 03 12:09 PM
Hi,
Check this sample also.
PERFORM bdc_dynpro USING 'SAPDM06Q' '0215'.
FORM bdc_dynpro USING program dynpro.
CLEAR w_bdcdata.
w_bdcdata-program = program.
w_bdcdata-dynpro = dynpro.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO i_bdcdata.
ENDFORM.
If you use 'Using','Changing','Tables' in form,then obviously you need to use the same in perform statement also.
2005 Aug 03 12:23 PM
hi sims, its not clear which all parameters you are using, so please do copy your total source code from the top till the bottom. then we can repeat the same fucntion module at our end too and can give you an appropriate solution,
but as of now we are unable to know which bare you import paranmters or export parameters.
thanks & regards,
venugopal
2005 Aug 03 12:31 PM
FUNCTION z_fs_allocated_payment_clear.
DATA BEGIN OF bdcdtab OCCURS 1.
INCLUDE STRUCTURE bdcdata.
DATA END OF bdcdtab.
DATA BEGIN OF messtab OCCURS 10.
INCLUDE STRUCTURE bdcmsgcoll.
DATA END OF messtab.
DATA BEGIN OF ybsid OCCURS 1.
INCLUDE STRUCTURE bsid.
DATA END OF ybsid.
PERFORM ybsid_fill tables ybsid.
PERFORM bdcdtab_fill tables bdcdtab.
PERFORM call_transaction.
endfunction.
*&----
*
*& Form bdcdtab_fill
*&----
*
text
*----
*
FORM bdcdtab_fill tables bdcdtab.
CLEAR bdcdtab.
REFRESH bdcdtab.
*-- Felder des Startdynpros der Ausgleichstransaktion füllen------
bdcdtab-program = 'SAPMF05A'.
bdcdtab-dynpro = '0131'.
bdcdtab-dynbegin = 'X'.
bdcdtab-fnam = ' '.
bdcdtab-fval = ' '.
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'RF05A-AGKON'.
bdcdtab-fval = '0000300730'. " This is The company CODE ie 300730
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BKPF-BUKRS'.
bdcdtab-fval = '2000'. "Company code ie 2000
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BKPF-WAERS'.
bdcdtab-fval = 'GBP'. "Currency which is GBP
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BKPF-BUDAT'.
WRITE AUGDT TO BDCDTAB-FVAL DD/MM/YYYY. "Augdt is todays date ie
20050712
bdcdtab-fval = '12.07.2005'. "Augdt is todays date ie 20050712
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BKPF-MONAT'.
bdcdtab-fval = '00'. " BMONAT need to check this one out
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'RF05A-XNOPS'.
bdcdtab-fval = 'X'.
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BDC_OKCODE'.
bdcdtab-fval = '/11'.
APPEND bdcdtab.
bdcdtab-program = 'SAPMF05A'.
bdcdtab-dynpro = '0700'.
bdcdtab-dynbegin = 'X'.
bdcdtab-fnam = 'BDC_OKCODE'.
bdcdtab-fval = '/ '.
APPEND bdcdtab.
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BDC_OKCODE'.
bdcdtab-fval = '/11'.
APPEND bdcdtab.
ENDFORM. "bdcdtab_fill
*&----
*
*& Form CALL_TRANSACTION
*&----
*
text
*----
*
FORM call_transaction.
REFRESH messtab.
CLEAR messtab.
EXPORT ybsid TO MEMORY ID '%F124%'.
CALL TRANSACTION 'FB1D' USING bdcdtab
MODE 'N'
UPDATE 'S'
MESSAGES INTO messtab.
ENDFORM. "CALL_TRANSACTION
*&----
*
*& Form ybsid_fill
*&----
*
text
*----
*
FORM ybsid_fill changing ybsid.
ybsid-mandt = '800'.
ybsid-bukrs = '2000'.
ybsid-kunnr = '0000300730'.
ybsid-umsks =
ybsid-umskz =
ybsid-augdt =
ybsid-augbl =
ybsid-zuonr = 'V31'.
ybsid-gjahr = '2005'.
ybsid-belnr = '1400000000'.
ybsid-buzei = '002'.
ybsid-budat = '20050703'.
ybsid-bldat = '20050703'.
ybsid-cpudt = '20050703'.
ybsid-waers = 'GBP'.
ybsid-xblnr =
ybsid-blart = 'DZ'.
ybsid-monat = '07'.
ybsid-bschl = '15'.
ybsid-zumsk =
ybsid-shkzg = 'H'.
ybsid-gsber =
ybsid-mwskz =
ybsid-dmbtr = '1175.00'.
ybsid-wrbtr = '1175.00'.
ybsid-mwsts =
ybsid-wmwst =
ybsid-bdiff =
ybsid-bdif2 =
ybsid-sgtxt =
ybsid-projn =
ybsid-aufnr =
ybsid-anln1 =
ybsid-anln2 =
ybsid-saknr = '0000140000'.
ybsid-hkont = '0000140000'.
ybsid-fkont =
ybsid-filkd =
ybsid-zfbdt = '20050703'.
ybsid-zterm =
ybsid-zbd1t =
ybsid-zbd2t =
ybsid-zbd3t =
ybsid-zbd1p =
ybsid-zbd2p =
ybsid-skfbt =
ybsid-sknto =
ybsid-wskto =
ybsid-zlsch =
ybsid-zlspr =
ybsid-zbfix =
ybsid-hbkid =
ybsid-bvtyp =
ybsid-rebzg = '1400000000'.
ybsid-rebzj =
ybsid-rebzz =
ybsid-samnr =
ybsid-anfbn =
ybsid-anfbj =
ybsid-anfbu =
ybsid-anfae =
ybsid-mansp =
ybsid-mschl =
ybsid-madat =
ybsid-manst =
ybsid-maber =
ybsid-xnetb =
ybsid-xanet =
ybsid-xcpdd =
ybsid-xinve =
ybsid-xzahl = 'X'.
ybsid-mwsk1 =
ybsid-dmbt1 =
ybsid-wrbt1 =
ybsid-mwsk2 =
ybsid-dmbt2 =
ybsid-wrbt2 =
ybsid-mwsk3 =
ybsid-dmbt3 =
ybsid-wrbt3 =
ybsid-bstat =
ybsid-vbund =
ybsid-vbeln =
ybsid-rebzt =
ybsid-infae =
ybsid-stceg =
ybsid-egbld =
ybsid-eglld =
ybsid-rstgr =
ybsid-xnoza =
ybsid-vertt =
ybsid-vertn =
ybsid-vbewa =
ybsid-wverw =
ybsid-projk =
ybsid-fipos = '9620'.
ybsid-nplnr =
ybsid-aufpl =
ybsid-aplzl =
ybsid-xegdr =
ybsid-dmbe2 = '1654.93'.
ybsid-dmbe3 =
ybsid-dmb21 =
ybsid-dmb22 =
ybsid-dmb23 =
ybsid-dmb31 =
ybsid-dmb32 =
ybsid-dmb33 =
ybsid-bdif3 =
ybsid-xragl = 'X'.
ybsid-uzawe =
ybsid-xstov =
ybsid-mwst2 =
ybsid-mwst3 =
ybsid-sknt2 =
ybsid-sknt3 =
ybsid-xref1 =
ybsid-xref2 =
ybsid-xarch =
ybsid-pswsl = 'GBP'.
ybsid-pswbt = '1175.00'.
ybsid-lzbkz =
ybsid-landl =
ybsid-imkey =
ybsid-vbel2 =
ybsid-vpos2 =
ybsid-posn2 =
ybsid-eten2 =
ybsid-fistl =
ybsid-geber =
ybsid-dabrz =
ybsid-xnegp =
ybsid-kostl =
ybsid-rfzei =
ybsid-kkber = '1000'.
ybsid-empfb =
ybsid-prctr =
ybsid-xref3 =
ybsid-qsskz =
ybsid-zinkz =
ybsid-dtws1 =
ybsid-dtws2 =
ybsid-dtws3 =
ybsid-dtws4 =
ybsid-xpypr =
ybsid-kidno =
ybsid-absbt =
ybsid-ccbtc =
ybsid-pycur =
ybsid-pyamt =
ybsid-bupla =
ybsid-secco =
ybsid-cession_kz =
ybsid-ppdiff =
ybsid-ppdif2 =
ybsid-ppdif3 =
ybsid-kblnr =
ybsid-kblpos =
ybsid-grant_nbr =
ybsid-gmvkz =
ybsid-srtype =
ybsid-lotkz =
ybsid-fkber =
ybsid-intreno =
ybsid-pprct =
ybsid-buzid =
ybsid-auggj =
ybsid-kontt =
ybsid-kontl =
ybsid-uebgdat =
ybsid-vname =
ybsid-egrup =
ybsid-btype =
APPEND ybsid.
SELECT SINGLE * FROM
bsid
INTO ybsid
WHERE bukrs = '2000'
AND kunnr = '0000300730'
AND gjahr = '2005'
AND ZUONR = 'V31'
AND belnr = '1800000000'.
**______________________________________________________________________
**
Now Deal with second line
**______________________________________________________________________
ybsid-mandt = '800'.
ybsid-bukrs = '2000'.
ybsid-kunnr = '0000300730'.
ybsid-umsks =
ybsid-umskz =
ybsid-augdt =
ybsid-augbl =
ybsid-zuonr = 'V31'.
ybsid-gjahr = '2005'.
ybsid-belnr = '1800000000'.
ybsid-buzei = '001'.
ybsid-budat = '20050703'.
ybsid-bldat = '20050630'.
ybsid-cpudt = '20050703'.
ybsid-waers = 'GBP'.
ybsid-xblnr = 'V3 PO 1'.
ybsid-blart = 'DR'.
ybsid-monat = '07'.
ybsid-bschl = '01'.
ybsid-zumsk =
ybsid-shkzg = 'S'.
ybsid-gsber =
ybsid-mwskz = 'A1'.
ybsid-dmbtr = '1175.00'.
ybsid-wrbtr = '1175.00'.
ybsid-mwsts =
ybsid-wmwst =
ybsid-bdiff =
ybsid-bdif2 =
ybsid-sgtxt = 'Service item'.
ybsid-projn =
ybsid-aufnr =
ybsid-anln1 =
ybsid-anln2 =
ybsid-saknr = '0000140000'.
ybsid-hkont = '0000140000'.
ybsid-fkont =
ybsid-filkd =
ybsid-zfbdt = '20050703'.
ybsid-zterm = '0001'.
ybsid-zbd1t =
ybsid-zbd2t =
ybsid-zbd3t =
ybsid-zbd1p =
ybsid-zbd2p =
ybsid-skfbt = '1000.00'.
ybsid-sknto =
ybsid-wskto =
ybsid-zlsch =
ybsid-zlspr =
ybsid-zbfix =
ybsid-hbkid =
ybsid-bvtyp =
ybsid-rebzg = '1800000000'.
ybsid-rebzj =
ybsid-rebzz =
ybsid-samnr =
ybsid-anfbn =
ybsid-anfbj =
ybsid-anfbu =
ybsid-anfae =
ybsid-mansp =
ybsid-mschl =
ybsid-madat =
ybsid-manst =
ybsid-maber =
ybsid-xnetb =
ybsid-xanet =
ybsid-xcpdd =
ybsid-xinve =
ybsid-xzahl = ''.
ybsid-mwsk1 =
ybsid-dmbt1 =
ybsid-wrbt1 =
ybsid-mwsk2 =
ybsid-dmbt2 =
ybsid-wrbt2 =
ybsid-mwsk3 =
ybsid-dmbt3 =
ybsid-wrbt3 =
ybsid-bstat =
ybsid-vbund =
ybsid-vbeln =
ybsid-rebzt =
ybsid-infae =
ybsid-stceg =
ybsid-egbld =
ybsid-eglld =
ybsid-rstgr =
ybsid-xnoza =
ybsid-vertt =
ybsid-vertn =
ybsid-vbewa =
ybsid-wverw =
ybsid-projk =
ybsid-fipos = '9620'.
ybsid-nplnr =
ybsid-aufpl =
ybsid-aplzl =
ybsid-xegdr =
ybsid-dmbe2 = '1654.93'.
ybsid-dmbe3 =
ybsid-dmb21 =
ybsid-dmb22 =
ybsid-dmb23 =
ybsid-dmb31 =
ybsid-dmb32 =
ybsid-dmb33 =
ybsid-bdif3 =
ybsid-xragl = 'X'.
ybsid-uzawe =
ybsid-xstov =
ybsid-mwst2 =
ybsid-mwst3 =
ybsid-sknt2 =
ybsid-sknt3 =
ybsid-xref1 =
ybsid-xref2 =
ybsid-xarch =
ybsid-pswsl = 'GBP'.
ybsid-pswbt = '1175.00'.
ybsid-lzbkz =
ybsid-landl =
ybsid-imkey =
ybsid-vbel2 =
ybsid-vpos2 =
ybsid-posn2 =
ybsid-eten2 =
ybsid-fistl =
ybsid-geber =
ybsid-dabrz =
ybsid-xnegp =
ybsid-kostl =
ybsid-rfzei =
ybsid-kkber = '1000'.
ybsid-empfb =
ybsid-prctr =
ybsid-xref3 =
ybsid-qsskz =
ybsid-zinkz =
ybsid-dtws1 =
ybsid-dtws2 =
ybsid-dtws3 =
ybsid-dtws4 =
ybsid-xpypr =
ybsid-kidno =
ybsid-absbt =
ybsid-ccbtc =
ybsid-pycur =
ybsid-pyamt =
ybsid-bupla =
ybsid-secco =
ybsid-cession_kz =
ybsid-ppdiff =
ybsid-ppdif2 =
ybsid-ppdif3 =
ybsid-kblnr =
ybsid-kblpos =
ybsid-grant_nbr =
ybsid-gmvkz =
ybsid-srtype =
ybsid-lotkz =
ybsid-fkber =
ybsid-intreno =
ybsid-pprct =
ybsid-buzid =
ybsid-auggj =
ybsid-kontt =
ybsid-kontl =
ybsid-uebgdat =
ybsid-vname =
ybsid-egrup =
ybsid-btype =
APPEND ybsid.
ENDFORM. "ybsid_fill
2005 Aug 03 12:47 PM
Hi,
Declare bdcdtab and ybsid globally.
PERFORM ybsid_fill.
PERFORM bdcdtab_fill.
If you did so,this is enough.
FORM bdcdtab_fill.
...
Endform.
FORM ybsid_fill.
..
Endform.
This should work.If so,reward points by clicking the star on the left side of the reply.If you need clarifications,get back.
2005 Aug 03 12:51 PM
Hi,
I'm trying not to decalre them globally in the fuction group, so that if it needs to be called from other reports it can be. Is there an easy way just to pass it into the form from the function?
2005 Aug 03 1:06 PM
2005 Aug 03 1:17 PM
Hi,
Here is the sample.
data itab type standard table of zzz_makt.
data wa type zzz_makt.
perform form1 tables itab.
loop at itab into wa.
write 😕 wa.
endloop.
&----
*& Form form1
&----
text
----
-->P_ITAB text
----
form form1 tables p_itab .
data lv type zzz_makt.
lv-zmatnr = '33'.
lv-zmaktx = 'adas'.
lv-pick = 'X'.
append lv to p_itab.
endform. " form1
In your program,
FORM ybsid_fill <b>tables</b> ybsid.
2005 Aug 03 1:51 PM
Hi tried that,
and I get :
The data object "BDCDTAB" has no structure and therefore no component
the code is:
DATA BEGIN OF bdcdtab OCCURS 1.
INCLUDE STRUCTURE bdcdata.
DATA END OF bdcdtab.
PERFORM bdcdtab_fill tables bdcdtab.
.
.
.
FORM bdcdtab_fill tables bdcdtab.
CLEAR bdcdtab.
REFRESH bdcdtab.
*-- Felder des Startdynpros der Ausgleichstransaktion füllen------
bdcdtab-program = 'SAPMF05A'.
bdcdtab-dynpro = '0131'.
2005 Aug 03 1:54 PM
2005 Aug 03 1:26 PM
Hi Sims,
While calling PERFORM ybsid_fill tables ybsid. This statement is incorrect cause you are using
....'FORM ybsid_fill changing ybsid structure ybsid.'
Changing in the form call .. this is a conflicting rather i would suggest you to use it like this
PERFORM YBSID_FILL CHANGING YBSID
FORM YBSID....... CHANGING P_YBDID.
"Not only you are passing the same internal table name you are also appending. Note while using tables, changing statements require the reference
ENDFORM.
There is the same problem with the PERFORM bdcdtab_fill TABLES bdcdtab. cause u have used the same name in the FORM call.
Correct this and your code will work. it will not make any difference even it's via a FM call.
/Manik
2005 Aug 03 1:41 PM
In the FM code, you can not define any form routines.
All form routines have to be part of the Function Group.
Hope you are clear with this.
If you try to do soemthing like.
Function.
<Code>
end function.
form
...
endform.
it will give u a syntax error.
Remember to reward points to the replies that answered ur question.
2005 Aug 03 2:28 PM
Hi Sims,
You need to give a different name then 'bdcdtab' and as REICH said declare structure as well, though it not mandatory.
USe this code instead
PERFORM bdcdtab_fill tables bdcdtab.
.
.
.
FORM bdcdtab_fill tables p_bdcdtab structure bdcdtab
CLEAR bdcdtab.
REFRESH bdcdtab.
*-- Felder des Startdynpros der Ausgleichstransaktion füllen------
bdcdtab-program = 'SAPMF05A'.
bdcdtab-dynpro = '0131'.
I hope this will solve you problem
/Manik
2005 Aug 04 1:02 PM
Hi Sims,
If you problem is solved. Then please click the * (star) button and reward points.
/Manik