08-06-2010 12:36 AM
Hi Experts,
In the system there is a custom Function Module/Function group/Main Prog. I got a requirement to enhance it.
types: ty_likp type likp,
ty_lips type lips.
data: wa_likp type t_likp,
wa_lips type t_lips,
itab_likp type table of t_likp,
itab_lips type table of t_lips.
data: begin of it_invoice_items occurs 0,
vbeln like vbrk-vbeln,
posnr like vbrp-posnr,
end of it_invoice_items.
itab_lips[] = xlips[]. "xlips have 20 items
loop at it_invoice_items.
perform my_routine(my_program) USING itab_lips
it_invoice_items
flag_in
CHANGING wa_likp
flag_out.
"some other code comes here
endloop.
$$$$$$$$$$$$$$$$$
Report My_Program
FORM my_routine USING p_itab_lips
p_it_invoice_items
flag_in
CHANGING p_wa_likp
flag_out
move p_itab_lips-XYZ to p_wa_likp-XYZ
move p_it_invoice_items-ABC to p_wa_likp-ABC
Am getting an error against these formal parameters, as
"p_itab_lips" is not defined!
"p_it_invoice_items" is not defined!,
"p_wa_likp" is not defined!
1) So, is it mandatory to define them as below? (we are on ECC6.0)
becasue, am PASSING BY REFERENCE so they shuld get attributes from ACTUAL parameters right? then why system is throwing error?
FORM my_routine USING p_itab_lips TYPE itab_lips_1
p_it_invoice_items TYPE type_vbrp
p_flag_in type char1
CHANGING p_wa_likp TYPE type_likp
p_flag_out type char1
but, am stuck up in defining the itab_lips_1 "TABLE TYPE
2) pls. let me know How to define this TABLE TYPE of itab_lips_1?
FORM my_routine USING p_itab_lips TYPE itab_lips_1 "(where in VALUE clause is not used)
p_it_invoice_items TYPE type_vbrp
p_flag_in type char1
CHANGING p_wa_likp TYPE type_likp
p_flag_out type char1
3) Is the above ststement (where in VALUE clause is not used) is dangerous?
is it cumplsory to use the below stetement(where in VALUE clause is used) over the above statement?
FORM my_routine USING p_itab_lips TYPE itab_lips_1
p_it_invoice_items TYPE type_vbrp
VALUE(p_flag_in) type char1 "where in VALUE clause is used
CHANGING p_wa_likp TYPE type_likp
p_flag_out type char1
4) I guess, the REPORT my_program should be EXECUTABLE TYPE program, right? or else, as its Function Module/Function Group/Main Prog. so should I choose MODULE POOL prog for this my_program?
Thank you
08-06-2010 2:53 AM
Currently don't have SAP system so i am answering points 1, 3 & 4.
1) So, is it mandatory to define them as below? (we are on ECC6.0)
Untyped params are not possible in ABAP Objects. I think you can use untyped params in subroutines though. Not sure why it is giving the error.
3) In the above ststement (where in VALUE clause is not used) is dangerous?
If you add the VALUE addition internally a local variable of same type as the actual param is created & the value of the actual param is copied into it.
This is not so performance friendly if you've huge tables being passed BY VALUE. In your case this is a flag, i don't foresee any major performance issues using it.
4) I guess, the REPORT my_program should be EXECUTABLE TYPE program, right? or else, as its Function Module/Function Group/Main Prog. so should I choose MODULE POOL prog for this my_program?
I would go for a subroutine-pool type program (like the one you define for SAPscript subroutines)
BR,
Suhas
Edited by: Suhas Saha on Aug 6, 2010 7:32 AM
08-06-2010 2:53 AM
Currently don't have SAP system so i am answering points 1, 3 & 4.
1) So, is it mandatory to define them as below? (we are on ECC6.0)
Untyped params are not possible in ABAP Objects. I think you can use untyped params in subroutines though. Not sure why it is giving the error.
3) In the above ststement (where in VALUE clause is not used) is dangerous?
If you add the VALUE addition internally a local variable of same type as the actual param is created & the value of the actual param is copied into it.
This is not so performance friendly if you've huge tables being passed BY VALUE. In your case this is a flag, i don't foresee any major performance issues using it.
4) I guess, the REPORT my_program should be EXECUTABLE TYPE program, right? or else, as its Function Module/Function Group/Main Prog. so should I choose MODULE POOL prog for this my_program?
I would go for a subroutine-pool type program (like the one you define for SAPscript subroutines)
BR,
Suhas
Edited by: Suhas Saha on Aug 6, 2010 7:32 AM
08-06-2010 3:51 AM
Thank you Saha.
Experts, pls answer my 2nd question that How Can I define that TABLE TYPE data object so that I can use it as TYPE declaration in my_routine.
Thank you
08-06-2010 4:36 AM
Hi,
DATA : itab TYPE STANDARD TABLE OF sflight WITH HEADER LINE. " You can declare a table type like this
PARAMETERS : carrid type spfli-carrid.
PERFORM get_data TABLES itab
USING carrid.
LOOP AT itab.
WRITE 😕 itab-CARRID, ITAB-CONNID.
ENDLOOP.
FORM get_data TABLES itab
USING carrid.
SELECT * FROM sflight INTO TABLE itab." UP TO 5 ROWS .
DESCRIBE TABLE itab LINES sy-tfill. " Just copy this to a test program and Execute
ENDFORM. "get_data
Cheerz
Ram