Application Development 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: 

table type query

Former Member
0 Kudos

how do i dispaly the contents of a table type variable..

its urgent

answers will be rewrded.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rohan

Declare a workarea type structure used in the table type .

and read or loop and transfer into the workarea and display the workarea.

PLease reward if useful.

8 REPLIES 8

Former Member
0 Kudos

loop at itab.

write:/ itab-field1, itab-filed2,itab-field3.

endloop.

Former Member
0 Kudos

Hi Rohan

Declare a workarea type structure used in the table type .

and read or loop and transfer into the workarea and display the workarea.

PLease reward if useful.

former_member181962
Active Contributor
0 Kudos

Asdsome that t_tabtyp is the table type;

then

data: v_tabtyp type t_tabtyp. " v_tabtyp will be a table without a header line.

data: wa like line of v_tabtyp. " work area

then you can simply loop at v_tabtyp

loop at v_tabtyp into wa.

endloop.

Regards,

Ravi

sourabhshah
Advisor
Advisor
0 Kudos

hi Rohan,

if it is a variable(itab) with type table type then this is a internal table.

to display contents

data: wa type <table type>

Loop at itab into wa.

write wa.

  • if only few fields need to be displayed

write: wa-field1,

wa-field2.

endloop.

Former Member
0 Kudos

hi,

Here is a sample code


data: itab type vbap_t,
      wa_itab like line of itab.
select * from vbap
into table itab
where vbeln = '0000004969'.
if sy-subrc = 0.
  loop at itab into wa_itab.
    write : wa_itab-vbeln.
  endloop.
endif.

Regards

Sailaja.

sourabhshah
Advisor
Advisor
0 Kudos

Hi

if it is a variable(itab) with type table type then this is a internal table.

to display contents

data: wa like line of itab.

Loop at itab into wa.

write wa.

  • if only few fields need to be displayed

write: wa-field1,

wa-field2.

endloop.

Regards,

Sourabh

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

data : itab type standard table of mara,

wa type mara.

select * from mara into table itab.

loop at itab into wa.

write / wa-matnr.

endloop.

Former Member
0 Kudos

Hi Rohan,

Try this code:

TABLES: mara,marc.

TYPES: BEGIN OF t_mara,

matnr LIKE mara-matnr,

matkl LIKE mara-matkl,

END OF t_mara,

BEGIN OF t_marc,

matnr LIKE mara-matnr,

werks LIKE marc-werks,

dispo LIKE marc-dispo,

bstma LIKE marc-bstma,

END OF t_marc,

BEGIN OF t_display,

matnr LIKE mara-matnr,

matkl LIKE mara-matkl,

werks LIKE marc-werks,

dispo LIKE marc-dispo,

bstma LIKE marc-bstma,

END OF t_display.

DATA: itab TYPE STANDARD TABLE OF t_mara WITH DEFAULT KEY,

jtab TYPE STANDARD TABLE OF t_marc WITH DEFAULT KEY,

i_display TYPE STANDARD TABLE OF t_display WITH DEFAULT KEY.

DATA: wa_itab TYPE t_mara,

wa_jtab TYPE t_marc,

wa_display TYPE t_display.

SELECT matnr matkl FROM mara INTO TABLE itab

WHERE matnr EQ p_matnr.

IF NOT itab[] IS INITIAL.

SELECT matnr werks dispo bstma FROM marc INTO TABLE jtab

FOR ALL ENTRIES IN itab

WHERE matnr = itab-matnr

AND matnr = p_matnr.

LOOP AT itab INTO wa_itab.

READ TABLE itab INTO wa_itab WITH KEY matnr = p_matnr.

IF sy-subrc = 0.

wa_display-matnr = wa_itab-matnr.

wa_display-matkl = wa_itab-matkl.

APPEND wa_display TO i_display.

ENDIF.

ENDLOOP.

LOOP AT jtab INTO wa_jtab.

READ TABLE jtab INTO wa_jtab

WITH KEY matnr = p_matnr BINARY SEARCH.

IF sy-subrc = 0.

wa_display-werks = wa_jtab-werks.

wa_display-dispo = wa_jtab-dispo.

wa_display-bstma = wa_jtab-bstma.

APPEND wa_display TO i_display.

ENDIF.

ENDLOOP.

LOOP AT i_display INTO wa_display.

WRITE:/1 wa_display-matnr,

20 wa_display-matkl,

47 wa_display-werks,

53 wa_display-dispo,

60 wa_display-bstma.