‎2010 Oct 06 10:10 AM
Hi Guys,
I am very new to ABAP. I am facing one issue while changing the exist program.
In Selection screen:
SELECT-OPTIONS: PT_MATNR FOR MARA-MATNR.
*--------Produkthierarchie
SELECT-OPTIONS: PT_PRDHA FOR MARA-PRDHA.Perform Statment:
PERFORM get_common_data TABLES pt_prdha
pt_lifnrIn Form:
FORM get_common_data TABLES it_prdha STRUCTURE pt_prdha
it_lifnr STRUCTURE pt_lifnrWhen i try to activate the program it is giving the error
"field pt_prdha is unknown. It is neither in one of the specified tables nor defined by data statment"
Moderator message: please use more descriptive subject lines and code tags from now on.
Edited by: Thomas Zloch on Oct 6, 2010 12:44 PM
‎2010 Oct 06 10:24 AM
hi ,
First try to understand Flow of program before changing .
check syntax for perform and form .
i.e perform getdata .
form getdata.
endform "getdata
Regards
Deepak.
‎2010 Oct 06 10:26 AM
Hi sivaparvathy,
The select options name that you declare for a field always creates an internal table. But you can't refer that in the form statement since it's not a standard structure like SFLIGHT or user defined struc say for ex. Thats you it shoots an error. I guess thats the probs. Try with different structure for that table you are using in the form statement rather than the select-options internal table...I dont know for sure...Try and check it out
""Just checked your code....no error in the part pt_prdha but it triggers on pt_lifrnr. U gotta declare that before either in a structure format or itab since you are referring that for a formal parameter in the FORM statement."""
Regards,
Arunmozhi
‎2010 Oct 06 10:27 AM
hey remove the structure in form just use those ranges.
Thanks,
Vinayaka
‎2010 Oct 06 10:28 AM
Hi,
I suggest you that define PT_PRDHA using DATA statement
Else yiou define those by using BEGIN OF statement.i.e., inside structure u give define those fields.
The error tells that u need to define those before using it. I hope it will work
Regards,
Saravanan
‎2010 Oct 06 11:00 AM
PT_PRDHA - Is it global ???
if its in top include actiavte it first.
‎2010 Oct 06 11:35 AM
Hello,
I understand that PT_MATNR & PT_PRDHA are SELECT-OPTIONS. Also remember TABLES params is obsolete in subroutines & FMs, try to avoid them.
Recommended way of writing the code will be:
DATA: v_matnr TYPE mara-matnr,
v_prdha TYPE mara-prdha.
* Define Type Ranges for the SELECT-OPTIONs
TYPES: ty_r_matnr TYPE RANGE OF matnr,
ty_r_prdha TYPE RANGE OF prodh_d.
SELECT-OPTIONS:
s_matnr FOR v_matnr,
s_prdha FOR v_prdha.
PERFORM f_select_data
USING s_matnr[] s_prdha[].
*&---------------------------------------------------------------------*
*& Form F_SELECT_DATA
*&---------------------------------------------------------------------*
FORM f_select_data
USING fp_s_matnr TYPE ty_r_matnr
fp_s_prdha TYPE ty_r_prdha.
ENDFORM. " F_SELECT_DATABR,
Suhas
‎2010 Oct 06 11:47 AM
Hi,
STRUCTURE pt_prdha
after keyword STRUCTURE a dictionary structure is expected. You can try with LIKE pt_prdha.
Warning: It is always a little bit complicated to pass select-options tables as parameters. Select-options are global data in the program. In this case I would just use the field PT_PRDHA (after renaming to SO_PRDHA) in the subroutine.
And: Please avoid meaningless subjects as +Issue in ABAP Program+
If you are new to this forum, first take some time for reading before posting. Thank you.
Regards,
Clemens
‎2010 Oct 06 11:53 AM
Hello Clemens,
Select-options are global data in the program. In this case I would just use the field PT_PRDHA (after renaming to SO_PRDHA) in the subroutine.
I'm share the same opinion as you do. But the self-proclaimed "omniscient" QA reviewers here have different ideas. Is this documented somewhere or is it just a thumb-rule?
BR,
Suhas
‎2010 Oct 06 3:50 PM
Suhas,
for the self-proclaimed "omniscient" QA reviewers do as follows:
data:
l_ref type ref to data.
get reference of so_whatever into l_ref.
perform select using l_ref.
*...
form select using p_ref type ref to data.
field-symbols:
<selopt> type table.
assign p_ref to <selopt>.
select ...
into ...
from ....
where field in <selopt>.
endform.You can argue that this is modern oo oriented best-performance elaborated style. QA reviewers are usually just not qualified for disagreement
But honestly: With oo the use of references get's used more and more, so why not use them?
Regards,
Clemens
‎2010 Oct 06 5:32 PM
Hi Sivaparvathy,
First, the error is because pt_prdha and pt_lifnr are not in dictionary so, you can't use STRUCTURE, yo must use LIKE (because this tables belong to program).
aditionally:
- TABLES parameter is obsolete, so avoid use it.
- If your program is a REPORT all variables in selection screen are Globals, so you don't need pass it. (just use it)
SELECT-OPTIONS: PT_MATNR FOR MARA-MATNR.
*--------Produkthierarchie
SELECT-OPTIONS: PT_PRDHA FOR MARA-PRDHA.
PERFORM get_common_data.
FORM get_common_data.
...
READ TABLE PT_MATNR INDEX 1.
...
ENDFORM.I hope to be clear and usefull,
best regards.