Skip to Content
0
Former Member
Apr 22, 2009 at 04:37 PM

Select statement (new to ABAP)

672 Views

Hi, I just get to know ABAP and have been studying about it. I'm practising an exercise in which i use select statement to retrieve data from many tables with the same field. The tables i use are COSS, AFVC, PRPS and IMZO with the same field OBJNR. The data i need to retrieve is POSNR from table IMZO. This is the code that i've just written. Howvever, when i execute it, it said 'Unable to interpret t_imobj-posnr'. I think the code is not right somehow. Very appreciate any guides.

REPORT  Z_IMPOS_TEST.

TABLES: coss,       "CO Object: Cost Totals for Internal Postings
        afvc,       "Operation within an order
        prps,       "WBS (Work Breakdown Structure) Element Master Data
        imzo.       "Table: CO Object - Capital Investment Prog.Pos.

TYPES: BEGIN OF st_impos,
  objnr       TYPE coss-objnr,
  gjahr       TYPE coss-gjahr,
  pspnr       TYPE prps-pspnr,
  posnr       TYPE imzo-posnr,
END OF st_impos.

DATA : st_imobj    TYPE st_impos,
       t_imobj     TYPE STANDARD TABLE OF st_impos.

*PARAMETERS: p_year TYPE coss-gjahr OBLIGATORY.

SELECT objnr gjahr
      INTO CORRESPONDING FIELDS OF st_imobj
      FROM  coss
      WHERE objnr = st_imobj-objnr
      AND  gjahr = '2007'.
   SELECT objnr
      INTO st_imobj-objnr
      FROM afvc
      WHERE projn = st_imobj-pspnr.
         SELECT objnr
         INTO st_imobj-objnr
         FROM imzo
         WHERE posnr = st_imobj-posnr.
         st_imobj-posnr = st_imobj-posnr.
         st_imobj-gjahr = '2007'.
         APPEND st_imobj TO t_imobj.
         ENDSELECT.
    ENDSELECT.
  ENDSELECT.
  
  WRITE: 'InvProgPosition is : '  t_imobj-posnr.