‎2007 Aug 15 8:27 PM
Hi Gurus,
I have written the following code using Case and End case.
loop at it_header.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select kunn2 into it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select kunnr into it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select kunnr into it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
and I am getting the error message " when is allowed only after case".
Can you please try to help me out of this.
Thanks
Rajeev Gupta
‎2007 Aug 15 8:34 PM
Looks like you select statement are screwing it up. If you wish to get data into an internal table, use the word TABLE in your select statement.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select kunn2 into TABLE it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select kunnr into TABLE it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select kunnr into TABLE it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
Of if you need a single record us the SINGLE word in your select statements.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select SINGLE kunn2 into it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select SINGLE kunnr into it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select SINGLE kunnr into it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
Regards,
Rich Heilman
‎2007 Aug 15 8:32 PM
Hi Rajeev,
Expecting that you may be you forget to put ENDLOOP for LOOP.
Thanks,
Vinay
‎2007 Aug 15 8:33 PM
‎2007 Aug 15 8:34 PM
Looks like you select statement are screwing it up. If you wish to get data into an internal table, use the word TABLE in your select statement.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select kunn2 into TABLE it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select kunnr into TABLE it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select kunnr into TABLE it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
Of if you need a single record us the SINGLE word in your select statements.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select SINGLE kunn2 into it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select SINGLE kunnr into it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select SINGLE kunnr into it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
Regards,
Rich Heilman
‎2007 Aug 15 8:34 PM
HI,
Check this corrected code
loop at it_header.
case it_header-custty.
when 'ST'.
continue.
when 'BG'.
select single kunn2 into it_knvp from knvp
where parvw = 'ZB'
and kunnr = it_header-custid.
when 'PG'.
select single kunnr into it_knvh from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
when 'HQ'.
select single kunnr into it_knvh1 from knvh
where hityp = 'A'
and hkunnr = it_header-custid.
endcase.
endloop.
Thanks,
mahesh
‎2007 Aug 15 8:34 PM
i don't think you can write logic statements like where parvw = 'ZB' while using when statement..it should always be when 'Value' like
when '1'
when '2'
when var1.
Hope this helps.
Rajeev