‎2009 Feb 11 3:54 AM
Hi all,
Iam new to abap.
I have to write a report in internal table , for 1 header item related child items must exist,suppose if header is org then the child like branches in diff cities must be printed under that org and other org ther related branches etc.
can u tell me how i have to approach this with code.
Thanx.
‎2009 Feb 11 3:59 AM
Hi,
Try to use REUSE_ALV_HIERSEQ_LIST_DISPLAY function module which will display both header and items in hierarchical format.
‎2009 Feb 11 4:02 AM
Hi,
check out this code.
data:
begin of fs_branch,
...
...
end of fs_branch.
data:
t_branch like standard table of fs_branch.
data:
begin of fs_org,
...
branch like t_branch,
end of fs_org.
data:
t_org like standard table of fs_org,
append the data in both org and branches.
while looping,
loop at t_org inot fs_org.
write: / fs_org.
loop at fs_org-branch to fs_branch.
write: / fs_branch.
endloop.
skip.
endloop.
‎2009 Feb 11 4:02 AM
Hi,
Use control events like AT NEW
First declare a structure,
Ex:
sort itab by ORG.
Loop at itab into fs_tab.
AT NEW ORG.
write:/ Organization field.
endat.
write:/ BRANCH FIELD,
/ CITY FIELD.
endloop.
‎2009 Feb 11 4:04 AM
Hi ,
You can comapare this with the contents of DB table SPFLI .In that for each Carrid ( suppose AA ) There may be one or more than Connid ( 0017 and 0064 ) .
So if you want take that carrid as Header and Connid as item ( for comparison ) , the code will be like this----
data : fs_spfli type spfli,
t_spfli like table of fs_spfli.
select * from SPFLI into table t_spfli.
loop at t_spfli into fs_spfli.
AT NEW carrid.
write:/ fs_spfli-carrid.
ENDAT.
write:/ fs_spfli-connid
endlooop.
‎2009 Feb 11 4:18 AM
Hi MJN,
U can either declare one internal table to hold the header & item data or u can declare two separate interal tables for each one of it.
Suppose i take only one internal table.
First declare a structure with all the relevant fields of the ORG & Branches then create an internal table for it.
Code:
TYPES:
Begin of t_struct,
org_field1 type <datatype> or <dataobj>,
org_field2 type <datatype> or <dataobj>,
branch_field1 type <datatype> or <dataobj>,
branch_field2 type <datatype> or <dataobj>,
END of t_struct.
Data:
t_data like table of t_struct with header line.
select <fields declared in struct> from ORG Inner Join Branch ON <org_field> = <branch_field>
where <some condition> into table t_data.
if sy-subrc <> 0.
message 'No Records Found:" type 'E'.
endif.
endselect.
Loop at t_data into t_data.
at new <org_field1>
write: org_field.
endat.
write: branch_field1, branch_field2.
endloop.This shall solve the issue.
Thanks
Ravi
‎2009 Feb 11 4:18 AM