on 04-13-2017 5:56 AM
Dear All,
I have a requirement that I want to display vendor master data in alv format .
I have few vendors which are opened in more than one company codes .
Lets say vendor code : 1048 is available in both company codes 1000 and 6000 .
so my requirement is to display this record as one .
vendor name company code
1048 abc 1000/6000
Above is the example .
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : P_VENDOR FOR LFA1-LIFNR.
SELECTION-SCREEN END OF BLOCK B1 .
START-OF-SELECTION .
SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR IN P_VENDOR .
SELECT * FROM LFB1 INTO TABLE IT_LFB1 FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR AND BUKRS IN (1000,6000).
LOOP AT IT_LFA1 INTO WA_LFA1 .
CLEAR WA_LFB1.
READ TABLE IT_LFB1 INTO WA_LFB1 WITH KEY LIFNR = WA_LFA1-LIFNR .
IF SY-SUBRC EQ 0 .
WA_FINAL-AKONT = WA_LFB1-AKONT.
WA_FINAL-BUKRS = WA_LFB1-BUKRS.
ENDIF.
ENDLOOP .
Above is fetching only one company code I need both company codes . 1000 and 6000 both concatenated in to one field .
So how to achieve this requirement .Please suggest some ideas .
Hi Deep,
It's not complex. first you need to change declare field WA_FINAL-BUKRS to character maybe leng 9 or 14 characters base on how many compay code for vender, then you can concatenate these company code to your field.
Below just a draft code, performace maybe not good, you need to improve performance.
LOOP AT IT_LFA1 INTO WA_LFA1 .
CLEAR WA_LFB1.
LOOP AT IT_LFB1 INTO WA_LFB1 WHERE LIFNR = WA_LFA1-LIFNR .
IF WA_FINAL-BUKRS IS INITIAL.
WA_FINAL-BUKRS = WA_LFB1-BUKRS.
ELSE.
CONCATENATE WA_FINAL-BUKRS WA_LFB1-BUKRS INTO WA_FINAL-BUKRS
SEPARATED BY '/'.
ENDIF.
ENDLOOP.
ENDLOOP .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.