2007 Feb 02 3:21 PM
Dear Experts,
I need to do the below requirement and i coudn't understand, can any body help on this.
<b>Join the delivery header table LIKP to delivery Line item Table LIPS and check whether any records exist for the delivery no entered on selection screen and delivery Type LR (returns delivery) and plant (LIPS-WERKS) combination stored in internal table a. If the records got are greater than zero, then populate the material no (LIPS-MATNR), quantity (LIPS-LFIMG) and plant (LIPS-WEKRS) in internal Table c. Then for each line in internal table c go to table MARC for material and plant stored in internal table c and get the country of origin (MARC-HERKL) and update in internal table c</b>
Pls provide the coding for the above
thnaks in advance
karthik
2007 Feb 02 3:28 PM
HI,
JOin the tables LIKP LIPS with VBELN.
NO need 2 internal tables.....
try this.......
<b>TABLES: LIKP, LIPS, MARC.
DATA: BEGIN OF I_A OCCURS 0,
VBELN LIKE LIKP-VBELN,
WERKS LIKE LIPS-WERKS,
LFIMG LIKE LIPS-LFIMG,
MATNR LIKE LIPS-MATNR,
HERKL LIKE MARC-HERKL,
END OF I_A.
DATA HERKL LIKE MARC-HERKL.
SELECT-OPTIONS : SO_VBELN FOR LIKP-VBELN.
SELECT LIKPVBELN LIPSWERKS LIPSLFIMG LIPSMATNR INTO CORRESPONDING
FIELDS OF TABLE I_A FROM LIKP INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN
WHERE LIKPVBELN IN SO_VBELN AND LIKPLFART = 'LR'.
IF NOT I_A IS INITIAL.
LOOP AT I_A.
SELECT SINGLE HERKL FROM MARC INTO HERKL WHERE MATNR = I_A-MATNR AND
WERKS = I_A-WERKS.
IF SY-SUBRC = 0.
I_A-HERKL = HERKL.
ENDIF.
MODIFY I_A TRANSPORTING HERKL.
ENDLOOP.
ENDIF.
LOOP AT I_A.
WRITE: / I_A-WERKS, I_A-MATNR, I_A-HERKL.
ENDLOOP.
</b>
<b>Pls close the thread if the problem is solved and reward to all helpful answers.</b>
Regards
SAB
2007 Feb 02 3:33 PM
make a join select on LIKP and LIPS.
selection criterias as described in you requirement.
if sy-subrc NE 0.
select desired fields of MARC
where selektion criterias match your requirements.
endif.
i hope that clarifies your requirements a bit.
2007 Feb 02 4:26 PM
hi syed
Thnaks for the code.
This is what i have already return but one statement below i think you didn't noticed,
<b>and plant (LIPS-WERKS) combination stored in internal table a.</b>
i have an internal table A with LIPS-WERKS in top of my program i need to include in the quiry too. how can i include this?
Thanks
karthik
2007 Feb 02 4:42 PM
Try with the below logic
SELECT VBELN WERKS LFIMG MATNR
FROM LIPS INTO ITAB_A
WHERE VBELN IN S_VBELN (SELECTION SCREEN FIELD)
IF SY-SUBRC = 0.
SELECT VBELN
FROM LIKP
INTO TAB_B
FOR ALL ENTRIES IN ITAB_A
WHERE VBELNR = ITAB_A-VBELN
AND WERKS = ITAB_A-WERKS
AND LFART = 'LR'.
SELECT MATNR WERKS HERKL
FROM MARC INTO TABLE ITAB_C
FOR ALL ENTRIES IN ITAB_A
WHERE MATNR = ITAB_A-MATNR
AND WERKS = ITAB_A-WERKS.
LOOP AT ITAB_A.
READ TABLE ITAB_B WITH KEY VBELN = ITAB_A-VBELNR
WERKS = ITAB_A-WERKS
CHECK SY-SUBRC = 0.
READ TABLE ITAB_C WITH KEY MATNR = ITAB_A-MATNR
WERKS = ITAB_A-WERKS
IF SY-SUBRC = 0.
ITAB_A-HERKL = HERKL.
ENDIF.
MODIFY I_A TRANSPORTING HERKL.
ENDIF.
ENDLOOP.
ENDIF.
Regards,
Satya
LOOP AT I_A.
WRITE: / I_A-WERKS, I_A-MATNR, I_A-HERKL.
ENDLOOP.
2007 Feb 02 3:33 PM
Hello,
Do like this.
Select * from likp into table it_likp where vbeln in so_vbeln.
if not it_likp[] is initial.
select * from lips into table it_lips for all entries in it_likp
where vbelN = IT_LIKP-VBELN.
if sy-subrc = 0.
select * from marc into table it_marc for all entries in it_lips
where matnr = it_lips-matnr.
endif.
endif.
Now you need loop through the it_lips and it_marc and fill the final table.
Vasanth