Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issue in ABAP Program

Former Member
0 Likes
2,138

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_lifnr

In Form:

FORM get_common_data TABLES   it_prdha STRUCTURE pt_prdha
                              it_lifnr STRUCTURE pt_lifnr

When 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

10 REPLIES 10
Read only

deepak_dhamat
Active Contributor
0 Likes
1,394

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.

Read only

Former Member
0 Likes
1,394

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

Read only

Former Member
0 Likes
1,394

hey remove the structure in form just use those ranges.

Thanks,

Vinayaka

Read only

Former Member
0 Likes
1,394

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,394

PT_PRDHA - Is it global ???

if its in top include actiavte it first.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,394

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_DATA

BR,

Suhas

Read only

Clemenss
Active Contributor
0 Likes
1,394

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,394

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

Read only

Clemenss
Active Contributor
0 Likes
1,394

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

Read only

rxsalomone
Explorer
0 Likes
1,394

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.