cancel
Showing results for 
Search instead for 
Did you mean: 

Define Result Internal Table in Program Lines

Former Member
0 Kudos

Hi all

Im trying to do a loop in program lines in smartforms. This is my code in program lines:

DATA: BEGIN OF IT_COMP OCCURS 0,
      matnr LIKE resb-matnr,
      bdmng LIKE resb-bdmng,
      ebeln LIKE resb-ebeln,
      ebelp LIKE resb-ebelp,
      baugr LIKE resb-baugr,
  END OF IT_COMP.

DATA: p_BDMNG TYPE BSTMG,
      p_menge TYPE BSTMG,
      umrez LIKE MARM-UMREZ, "B.UOM qty
      umren LIKE MARM-UMREN. "A.UOM qty

select * into CORRESPONDING FIELDS OF IT_COMP
    from resb
    where baugr = <FS>-MATNR
    AND EBELN = <FS>-EBELN
    AND EBELP = <FS>-EBELP.
    ENDSELECT.

LOOP AT IT_COMP.

  WA_RESULT-MATNR = IT_COMP-MATNR.

  "PART DESC FROM MAKT
  select single maktx from makt
      into (WA_RESULT-p_maktx)
      where matnr = WA_RESULT-MATNR.

  "NET WEIGHT FROM MARA
  select single NTGEW from MARA
      into (WA_RESULT-P_NTGEW)
      where matnr = WA_RESULT-MATNR.

  "cal total qty
  p_BDMNG = IT_COMP-BDMNG.
  p_menge = <fs>-menge.
  wa_result-t_qty = p_menge * p_BDMNG.

  "cal total packs
  SELECT SINGLE UMREZ UMREN
    INTO (umrez, umren)
    FROM MARM
    WHERE MATNR = wa_result-MATNR
    AND MEINH = 'BAG'.

    wa_result-t_packs = ( wa_result-t_qty / umrez ) * umren.

ENDLOOP.

APPEND wa_result to it_result.
CLEAR wa_result.

And this is my definition in global definitions types tab.

TYPES: BEGIN OF s_result,
        MATNR LIKE RESB-MATNR,
        P_MAKTX LIKE MAKT-MAKTX,
        T_QTY LIKE ekpo-MENGE,
        T_PACKS LIKE ekpo-MENGE,
        P_NTGEW LIKE MARA-NTGEW,
  END OF s_result.

Types: t_result TYPE STANDARD TABLE OF s_result INITIAL SIZE 0.

In global data I define, "it_result type t_result" and "wa_result type s_result"

When I try to display the it_result in text node, "&IT_RESULT-MATNR&" , I get this error " "IT_RESULT" is a table without a header line and therefore has no component called "P_MAKTX". "

Please advise.

Thanks in advance

az

Edited by: alawiyah zakaria on Apr 22, 2008 10:17 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

A little correction in my first post.

The error msg is " "IT_RESULT" is a table without a header line and therefore has no component called "MATNR"."

Same error msg appear when I use other fields in it_result

Thanks

Former Member
0 Kudos

loop it_result into wa_result

and display wa_result

Former Member
0 Kudos

Hi Nehal Fronseca

Thanks for your reply.

Im looping at IT_COMP, not result.

Thanks

az

Former Member
0 Kudos

Hi ,

What i mean is . dont use the implict WA of the internal table.

You have to use a special workarea. defined spearately

Former Member
0 Kudos

Hi Nehal

Can you tell me how to define the separate workarea in more detail.

Really appreciate your reply.

Thanks

Former Member
0 Kudos

in global data.

WA type "your type"

assgin the data from your itab to this WA

Former Member
0 Kudos

Hi

You mean separate workarea definition for IT_COMP or RESULT

Former Member
0 Kudos

whichever one is thorwing the error alawiyah,

Former Member
0 Kudos

Hi,

The best way is to read the itab it_result into work area i.e wa_result based on some key values and use that work area in the text element. ( like this - &wa_result-matnr&).

Close previous threads once u move to new threads.

Regards,

Prabhu

Edited by: Prabhuraj Krishnan on Apr 22, 2008 4:09 PM

Former Member
0 Kudos

Hi

Is there any way to define itab it_result with header line?

How do people do when they want to display internal table for result which consist of fields from many table.

If the fields are from only one table, then there's no problem to define the internal table, right?

Please advise.

Thanks

az