05-17-2017 5:33 AM
Hi all.
asuming I have two DB-tables iwth identical fieldnames
Tablename #1 : Z_HUSBAND
Fields:
Tablename #1 : Z_WIFE
Fields:
The demand is to build a ALV Grip with both tables.
There are tow requirements
TYPES: BEGIN OF ty_hausband_wife_join,
BEGIN OF husband,
husband TYPE z_husband occurs 0,
end OF husband,
BEGIN OF wife,
wife TYPE z_wife occurs 0,
end OF wife,
data: lt_alv_columns type ty_hausband_wife_join.
My questions is now how to set up the populate the fieldcataloge dynamic an move the value of the z-tables (hausband & wife) by using move-corresponding.
Is there any dynamic workaround?
Regards
Mario
05-17-2017 7:19 AM
First, OCCURS is obsolete.
Use nested structures. For instance, you'll obtain fields husband-name and wife-name.
The field catalog will be generated automatically with SALV.
TYPES: BEGIN OF husband_wife,
husband TYPE z_husband,
wife TYPE z_wife,
END OF husband_wife.
TYPES husbands_wives TYPE TABLE OF husband_wife.
SELECT * INTO TABLE husbands_wives FROM husband INNER JOIN wife ON wife~couple_id = husband~couple_id.
05-17-2017 8:13 AM
HI Sandra,
really great work! It workes fo me.
As there could be divorced couples, I had to change the join INNER JOIN into a LEFT-JOIN
Thanks a lot!
Regards Mario
05-17-2017 8:39 AM
Hi Sandra,
do you have an idea how to generate the fieldcat from the types?
Danke, Grüße
Mario
05-18-2017 7:04 AM
Use SALV. Nothing to do. You may update the column attributes using the CL_SALV_COLUMN methods (via its subclasses).
05-17-2017 11:57 AM
Hi Mario,
we can generate fieldcatlog from structure by using function module 'REUSE_ALV_FIELDCATALOG_MERGE' . we need to pass the structure name i.e., globally declared structure(SE11).
Regards.
Sridhar. A