2009 Jul 06 1:07 PM
Hi all,
TYPES: BEGIN OF ZROUTE,
VBELN TYPE VBELN,
ROUTE TYPE ROUTE,
END OF ZROUTE.
DATA : IT_ZROUTE TYPE STANDARD TABLE OF ZROUTE,
WA_ZROUTE TYPE ZROUTE.
LOOP AT I_XVTTP_TAB INTO LW_XVTTP.
WA_ZROUTE-VBELN = LW_XVTTP-VBELN.
SELECT SINGLE ROUTE
INTO WA_ZROUTE-ROUTE
FROM LIKP
WHERE VBELN = LW_XVTTP-VBELN
APPEND WA_ZROUTE TO IT_ZROUTE.
ENDLOOP.
results from IT_ZROUTE
vbeln route
1111 A
2222 B
I have some problem in with the code below. I tried to collect vbeln and route into IT_ZROUTE.
However, after i've got the result, i want to do distiguish between the route.
If route A ne route B, then display an error messages.
My problem is, how do i compare the record by looping IT_ZROUTE? if i set into a temporary variable, the value will always change and i have prb in doing the comparison. eg:
loop it_zroute into wa_route.
zroute = wa_route-route. "set into a variable
if zroute = wa_route-route
"display error message
endif.
endloop.
Could anyone give me some tips to enhance my code? Really appreciate your help.
Hi all,
TYPES: BEGIN OF ZROUTE,
VBELN TYPE VBELN,
ROUTE TYPE ROUTE,
END OF ZROUTE.
DATA : IT_ZROUTE TYPE STANDARD TABLE OF ZROUTE,
WA_ZROUTE TYPE ZROUTE.
LOOP AT I_XVTTP_TAB INTO LW_XVTTP.
WA_ZROUTE-VBELN = LW_XVTTP-VBELN.
SELECT SINGLE ROUTE
INTO WA_ZROUTE-ROUTE
FROM LIKP
WHERE VBELN = LW_XVTTP-VBELN
APPEND WA_ZROUTE TO IT_ZROUTE.
ENDLOOP.
results from IT_ZROUTE
vbeln route
1111 A
2222 B
I have some problem in with the code below. I tried to collect vbeln and route into IT_ZROUTE.
However, after i've got the result, i want to do distiguish between the route.
If route A ne route B, then display an error messages.
My problem is, how do i compare the record by looping IT_ZROUTE? if i set into a temporary variable, the value will always change and i have prb in doing the comparison. eg:
loop it_zroute into wa_route.
zroute = wa_route-route. "set into a variable
if zroute = wa_route-route
"display error message
endif.
endloop.
Could anyone give me some tips to enhance my code? Really appreciate your help.
2009 Jul 06 1:12 PM
Hi,
try using 'AT END OF'..
* To fetch the coverage count for each order line
LOOP AT it_zroute into wa_route.
lv_count = wa_route-route.
AT END OF route.
check with the previous value.
give error message.
ENDAT.
ENDLOOP.
2009 Jul 06 1:19 PM
Hi,
loop at i_zroute into wa_route.
if zroute = space .
zroute = wa_route.
else.
if zroute = wa_route. " I dont know you want to compare = or NE change accordingly
Error Message........
endif.
endif.
endloop.
Regards,
Smart Varghese
2009 Jul 06 1:29 PM
Hi,
You can use "On change of" to display error messages accordingly.
Thanks,
Kshitija
2009 Jul 06 1:53 PM
Hi dear,
Please look paste the following code that will bring the result what you want :
TYPES: BEGIN OF ZROUTE,
VBELN TYPE VBELN,
ROUTE TYPE ROUTE,
END OF ZROUTE.
DATA : IT_ZROUTE TYPE STANDARD TABLE OF ZROUTE,
WA_ZROUTE TYPE ZROUTE.
LOOP AT I_XVTTP_TAB INTO LW_XVTTP.
WA_ZROUTE-VBELN = LW_XVTTP-VBELN.
SELECT SINGLE ROUTE
INTO WA_ZROUTE-ROUTE
FROM LIKP
WHERE VBELN = LW_XVTTP-VBELN
read table it_zroute with key route = wa_zroute-route.
if sy-subrc = 0.
message 'You have already entered the route' type 'E'.
else.
APPEND WA_ZROUTE TO IT_ZROUTE.
endif.
ENDLOOP.
Rgds,
Parekh Nirav
2009 Jul 06 2:06 PM
Hi SW,
You should never use SELECT statement inside LOOP statement as it will affect performance of the program. Use FOR ALL ENTRIES for the same.
TYPES: BEGIN OF ZROUTE,
VBELN TYPE VBELN,
ROUTE TYPE ROUTE,
END OF ZROUTE.
DATA : IT_ZROUTE TYPE STANDARD TABLE OF ZROUTE,
WA_ZROUTE TYPE ZROUTE.
************Addition STARTS***********
data : I_XVTTP_TAB_temp like I_XVTTP_TAB occurs 0 with header line.
data : begin of likp_itab occurs 0,
vbeln like likp-vbeln,
route like likp-route,
end of likp_itab.
I_XVTTP_TAB_temp[] = I_XVTTP_TAB[].
sort I_XVTTP_TAB_temp by vbeln.
delete adjacent duplicates from I_XVTTP_TAB_temp comparing vebln.
select vbeln
route
into table likp_itab
for all entries in I_XVTTP_TAB_temp
where vbeln eq I_XVTTP_TAB_temp-vbeln.
if sy-subrc eq 0.
sort likp_itab by vbeln.
endif.
************Addition ENDS***************
LOOP AT I_XVTTP_TAB INTO LW_XVTTP.
WA_ZROUTE-VBELN = LW_XVTTP-VBELN.
****************Not required
SELECT SINGLE ROUTE
INTO WA_ZROUTE-ROUTE
FROM LIKP
WHERE VBELN = LW_XVTTP-VBELN
****************Not required
read table likp_itab witj key vbeln = LW_XVTTP-VBELN binary search.
if sy-subrc eq 0.
WA_ZROUTE-ROUTE = likp_itab-route.
endif.
APPEND WA_ZROUTE TO IT_ZROUTE.
*********Add
clear wa_zroute.
*********Add
ENDLOOP.
Please explain the later part again I am not clear with requirement.
Regards,
Anil Salekar
2009 Jul 08 10:11 AM
Thanks alot for all your guidance. i managed to find the solution with all your help.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |