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

interactive report

Former Member
0 Likes
542

i m creating a int report.

i have 1 int table in which records r like D001,D002,D003,D004 etc.

i have to create 1 more table with 2 fields like successor & predesor and this should be related to first table. the req o/p should be

successor predesor

D002 D001

D003 D002

..........................

means first data should be in predesor after read successfully then only second data come in successor

what is the logic to relate these two fields and get req o/p

4 REPLIES 4
Read only

Former Member
0 Likes
502

hi,

can u explain it more.

Thanks and Regards

Suraj S Nair

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
502

Hello Vivek,

You can try this:

TYPES:
BEGIN OF ty1,
data TYPE string,
END OF ty1,

BEGIN OF ty2,
suc TYPE string,
pre TYPE string,
END OF ty2.

DATA:
itab1 TYPE STANDARD TABLE OF ty1,
wa1 TYPE ty1,
wa TYPE ty1,
itab2 TYPE STANDARD TABLE OF ty2,
wa2 TYPE ty2.

SORT itab1 by data.

LOOP AT itab1 INTO wa1.
  wa = wa1.
  AT FIRST.
    wa2-pre = wa-data.
    CONTINUE.
  ENDAT.

  wa2-suc = wa-data.
  APPEND wa2 TO itab2.
  CLEAR wa2.

  wa2-pre = wa-data.

  AT LAST.
    APPEND wa2 TO itab2.
    CLEAR wa2.
  ENDAT.
ENDLOOP.

BR,

Suhas

Edited by: Suhas Saha on Mar 27, 2009 11:04 AM

Read only

Former Member
0 Likes
502

Hi

Try this one.

DATA : v_index type sy-index.

describe i_tab1 lines v_index.

Loop at i_tab1 into wa_tab1.

if sy-index = '1'.

wa_tab2- field1 = ' '.

read i_tab1 index sy-index+1 into v_tab.

wa_tab2-field2 = v_tab.

else sy-index = v_index.

wa_tab2-field2 = ' '.

read i_tab1 index v_index-1 into v_tab.

wa_tab-field1 = v-tab.

else.

read i_tab1 index sy-index-1 into v_tab.

wa_tab-field1 = v_tab.

read i_tab1 index sy-index+1 into v_tab.

wa_tab2-field2 = v_tab.

endif.

Please tell if any problem is there to understand it.

Read only

Former Member
0 Likes
502

Hi,

Try this logic,

If itab consist of data like D001,D002,D003,D004 ...D010.

Sort itab by field descending.
Now data in itab will be D010,D009...D001.

LOOP AT ITAB.
  l_index = sy-tabix + 1.

  ITAB1-FIELD2 = ITAB-FIELD.
  READ ITAB INDEX l_index.
  IF SY-SUBRC EQ 0.
    ITAB1-FIELD1 = ITAB-FIELD.
    APPEND ITAB1.
  ENDIF.
ENDLOOP.