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

Problem with JOINs in SELECT query

Former Member
0 Likes
426

The parameter wa_dob-e_dob is not getting its definition ....

it contains DOB in current yr.

As i am using Joins also Workarea.... so is it coz Joins & WA cant be used simultaneously in a SELECT query....

Is there any other option to do the same...?

*---------------------------------------------------------------------*
*  Global Structure
*---------------------------------------------------------------------*
TYPES : BEGIN OF t_data ,                     "Structure
        emp_dob TYPE pa0002-gbdat,
        emp_Mailid TYPE pa0105-usrid,
       END OF t_data,

       BEGIN OF t_dob,
       e_dob TYPE pa0002-gbdat,
       e_pernr type pa0002-pernr,
       END OF t_dob.
*---------------------------------------------------------------------*
*  Global Internal Tables (I_)
*---------------------------------------------------------------------*
DATA : i_data TYPE TABLE OF t_data,           "Internal Table for output data

       i_dob TYPE TABLE OF t_dob.             "Internal table for Dob


*---------------------------------------------------------------------*
*  Global Work Area (WA_)
*---------------------------------------------------------------------*
DATA : wa_data TYPE  t_data,                  "Work Area for output data
       wa_dob TYPE  t_dob.                    "Work Area for Dob


*this is the query where i am getting error
* Field "WA_DOB-E_DOB" Not found.

LOOP AT i_dob INTO wa_dob.
    
    SELECT pa0002~gbdat pa0105~usrid INTO CORRESPONDING FIELDS OF wa_data
      FROM pa0002
      INNER JOIN pa0105
      ON pa0002~pernr = pa0105~pernr
      WHERE  pa0105~subty EQ 'MAIL' AND
     wa_dob-e_dob BETWEEN w_sysdate AND w_edit_sysdate.
    ENDSELECT.
    APPEND wa_data TO i_data.
    CLEAR wa_data.
    CLEAR wa_dob.
    CLEAR l_temp_dob.
 
  ENDLOOP.

The parameter wa_dob-e_dob is not getting its definition ....

it contains DOB in current yr.

As i am using Joins also Workarea.... so is it coz Joins & WA cant be used simultaneously in a SELECT query....

Is there any other option to do the same...?

*---------------------------------------------------------------------*
*  Global Structure
*---------------------------------------------------------------------*
TYPES : BEGIN OF t_data ,                     "Structure
        emp_dob TYPE pa0002-gbdat,
        emp_Mailid TYPE pa0105-usrid,
       END OF t_data,

       BEGIN OF t_dob,
       e_dob TYPE pa0002-gbdat,
       e_pernr type pa0002-pernr,
       END OF t_dob.
*---------------------------------------------------------------------*
*  Global Internal Tables (I_)
*---------------------------------------------------------------------*
DATA : i_data TYPE TABLE OF t_data,           "Internal Table for output data

       i_dob TYPE TABLE OF t_dob.             "Internal table for Dob


*---------------------------------------------------------------------*
*  Global Work Area (WA_)
*---------------------------------------------------------------------*
DATA : wa_data TYPE  t_data,                  "Work Area for output data
       wa_dob TYPE  t_dob.                    "Work Area for Dob


*this is the query where i am getting error
* Field "WA_DOB-E_DOB" Not found.

LOOP AT i_dob INTO wa_dob.
    
    SELECT pa0002~gbdat pa0105~usrid INTO CORRESPONDING FIELDS OF wa_data
      FROM pa0002
      INNER JOIN pa0105
      ON pa0002~pernr = pa0105~pernr
      WHERE  pa0105~subty EQ 'MAIL' AND
     wa_dob-e_dob BETWEEN w_sysdate AND w_edit_sysdate.
    ENDSELECT.
    APPEND wa_data TO i_data.
    CLEAR wa_data.
    CLEAR wa_dob.
    CLEAR l_temp_dob.
 
  ENDLOOP.

1 REPLY 1
Read only

Former Member
0 Likes
341

Hi,

you are checking the work area in the SELECT. IN WHERE condition of the select u should specify fields in either of the tables pa0002 , pa0105 for data population.

The select is on the database table and not on the work area.for checking the data in the work area do this way:

loop at it_dob into wa_dob.

if wa_dob-e_dob between the range u want (w_sysdate AND w_edit_sysdate)

endif.

endloop.

ie: wa_dob-e_dob >w_sysdate AND wa_dob-e_dob < w_edit_sysdate or

wa_dob-e_dob < w_sysdate AND wa_dob-e_dob > w_edit_sysdate

watever ur requirement is..

regards,

madhu