‎2009 Sep 29 8:06 AM
Hi,
I am working with a report. Input parameters as kunnr, hityp, hvkorg from the table knvh.
My data in the table is as
KUNNR vkorg hkunnr
10255 2001 30349
53344 2001 30349
45678 2001 30349
74152 2001 30349
In this i need to pick up all kunnr entries associated with hkunnr(30349). If input parameter
is HKUNNR then the below code is working but i have to keep KUNNR as input field.
For the above task i am coding like this
Can anyone help me how to replace HKUNNR with KUNNR.
‎2009 Sep 29 8:24 AM
Hi,
U rcdoe will work when the input paramter is hkunnr as it has four records and u will get , but when u go for kunnr u will get the kunnr entry whcih u specified in the selection screen...
my suggestion is use instead of kunnr use hkunnr in the selection screen... else once u get the data for kunnr.. for example i have given in the selection screen , kunnr as 10255 now i will get one record as 10255 2001 30349.
Now onec again query the same table now by using hkunnr = itab-hkunnr (using for all entries) u will get the rest of the records.
Regards,
Nagaraj
‎2009 Sep 29 8:32 AM
Hi Venkat,
You can try using;
SELECT B~KUNNR B~HITYP B~HKUNNR INTO TABLE ITAB
FROM KNVH AS A INNER JOIN
KNVH AS B ON B~HKUNNR = A~HKUNNR WHERE A~KUNNR = PA_CUST
AND A~HVKORG = PA_CCODE
AND A~HITYP = PA_HITYP.
I am not sure whether it works, just try and let me know.
regards
Karthik D
‎2009 Sep 29 8:57 AM
Solved by own.
Below is the code by which it is working fine.
LOOP AT ITAB.
IF ITAB-HKUNNR NE 0.
MOVE ITAB-HKUNNR TO LV_HKUNNR.
MOVE ITAB-HVKORG TO LV_CCODE.
MOVE ITAB-HITYP TO LV_HITYP.
ENDIF.
SELECT * FROM KNVH INTO TABLE ITAB1 WHERE HKUNNR = LV_HKUNNR
AND HVKORG = LV_CCODE
AND HITYP = LV_HITYP.
LOOP AT ITAB1.
WRITE: /2 ITAB1-HITYP, 4 ITAB1-KUNNR, 15 ITAB1-VKORG, 23 ITAB1-SPART, 35 ITAB1-HKUNNR.
ENDLOOP. "FOR ITAB
ENDLOOP. "FOR ITAB1.