Skip to Content
0

Showing All values in SQ02 query when joining

Dec 12, 2017 at 04:00 PM

79

avatar image

Hello

I'm trying to pass an approver or reviewer on a funds center that can be found from table HRP1001 field SOBID to table HRUS_D2 field US_NAME. This HRUS_D2 table is used for workflow substitutions. I'm having issues when I try to join these two together. I am wanting to see all the permanent substitutes for a user, field REP_NAME from table HRUS_D2, but when I execute the query, it only shows me the first one from one row. If there are more than one substitutes for a user, it does not show a new row with the other permanent substitute for the user. I've attempted to create an internal table to resolve the problem, but still no luck. I'm moving the information from the internal structure to my extra structure called Z_HRUS_D2, just a structure of table HRUS_D2. The field Z_SOBID is an extra field of HRP1001-SOBID. I know there is a character issue between HRP1001-SOBID (45 characters) and HRUS_D2-US_NAME (12 Characters) and I'm also having problems resolving this. Any help would be greatly appreciated!

Here is my code for the internal table:

DATA: LT_HRUS_D21 TYPE TABLE OF HRUS_D2,
 LS_HRUS_D21 LIKE LINE OF LT_HRUS_D21.

SELECT * FROM HRUS_D2 
INTO CORRESPONDING FIELDS OF
TABLE LT_HRUS_D21
WHERE US_NAME = Z_SOBID
 AND BEGDA <= sy-datum
 AND ENDDA >= sy-datum
 AND REPPR = ''
 AND ACTIVE = 'X'.

LOOP at LT_HRUS_D21 INTO LS_HRUS_D21.
MOVE-CORRESPONDING LS_HRUS_D21 TO Z_HRUS_D2.
ENDLOOP.
SQL
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jelena Perfiljeva
Dec 13, 2017 at 08:05 PM
0

I'm not sure about these particular tables and the question is a bit confusing as it mentions a join but then shows the ABAP code (added in Extras, I assume).

In general, in queries we cannot use Extras to add more lines than JOIN finds. For example, if I created an infoset using tables VBAK and VBAP then there would be as many lines in the resulting query as there are in VBAP table. There could be even more lines in VBEP, for example, and if I added it to JOIN then I'd get more lines. But if I used Extras and added a VBEP look-up there then this would not add more lines to the result. Extras can only be used to add more data to the existing lines or to remove some data.

If this is the issue then either you have to redesign infoset to work the other way around (i.e. start with the table that has largest number of records and use Extras to add more info from other tables) or you'd need to write an ABAP report instead. Custom report might be more efficient though.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you Jelena for the information!

Yes, these were extra fields. I've been thinking about your comment, and I have reversed the logic instead of starting with the funds center and showing many approvers are on the funds center to start with the permanent subs for principal sub then passing to the approver on a funds center and getting the funds center.

Thank you!

Chad

0