‎2009 Sep 14 8:50 AM
HI ALL,
in the program,i need to display description based on condition type.
so we used CASE statement as below in LOOP. ITS not working .
could anyone please suggest if anything wrong in the following code.
LOOP AT gt_mat.
MOVE gt_mat-type TO gt_final-type.
Condition description
CASE gt_mat-type .
when 'N'.
move 'New' to gt_final-condes.
when 'B'.
move 'Block' to gt_final4-condes.
ENDCASE.
ENDLOOP.
please let me know whats the problem i above code and how to solve.
thanks in advance.
‎2009 Sep 14 8:52 AM
Its not working is not an error message. If gt_final-codes is not filled, gt_mat-type does not contain 'N' or 'B'.
‎2009 Sep 14 8:56 AM
Hi,
Your code is syntactically correct. Debug the code and check if gt_mat-type has the values 'N' or 'B'.
Regards,
Vikranth
‎2009 Sep 14 9:08 AM
we have the value in gt_mat-type as N.
It is not at all going inside the case statement.
CASE gt_mat-type .
when 'N'.
move 'New' to gt_final-condes.
when 'B'.
move 'Block' to gt_final4-condes.
ENDCASE.
‎2009 Sep 14 9:11 AM
Hi
check your data type for the filed :gt_mat-type is Character or not?
If not change that to Character.
Regards,
Sreeram
‎2009 Sep 14 9:12 AM
>
> we have the value in gt_mat-type as N.
> It is not at all going inside the case statement.
Hello,
I trust SAP on this. May be there is some "other" problem
Is the case stmt inside any loop control stmt (like AT NEW...ENDAT) ?
Suhas
‎2009 Sep 14 9:29 AM
>
> we have the value in gt_mat-type as N.
>
> It is not at all going inside the case statement.
>
> CASE gt_mat-type .
> when 'N'.
> move 'New' to gt_final-condes.
> when 'B'.
> move 'Block' to gt_final4-condes.
> ENDCASE.
Put WHEN OTHERS and see if it goes inside the CASE statement.
Also, as Venkat said, you need to put an APPEND gt_final or MODIFY gt_final to get the values as required.
‎2009 Sep 14 8:59 AM
hi
plz check the values of gt_final-type field.
the value you specified in quote for eg 'N' is case sensitive(ie n NE N).
Cheers,
Hakim
‎2009 Sep 14 9:01 AM
Hi
MOVE gt_mat-type TO gt_final-type.
First check the value of gt_final-type.before using the CASE statement.
you are using MOVE gt_mat-type TO gt_final-type.check the datatypes of gt_mat-type and gt_final-type first.
Regards,
Sreeram
‎2009 Sep 14 9:14 AM
Hi Sree,
<li> Are you appending or modifying GT_FINAL and GT_FINAL4 tables after you passing text to field condes.
Thanks
Venkat.OLOOP AT GT_MAT.
MOVE GT_MAT-TYPE TO GT_FINAL-TYPE.
* Condition description
CASE GT_MAT-TYPE .
WHEN 'N'.
MOVE 'New' TO GT_FINAL-CONDES.
APPEND GT_FINAL.
"or
MODIFY GT_FINAL TRANSPORTING CONDES.
WHEN 'B'.
MOVE 'Block' TO GT_FINAL4-CONDES.
APPEND GT_FINAL.
"or
MODIFY GT_FINAL4 TRANSPORTING CONDES.
ENDCASE.
ENDLOOP.
‎2009 Sep 14 9:30 AM
Hi,
The only solution for this could be to debug the program and check if the coresponding values are populated and available. You could also try to replace the CASE statement with a simple IF statement and check if its working.
LOOP AT gt_mat.
MOVE gt_mat-type TO gt_final-type.
* Condition description
IF gt_mat-type = 'N'.
gt_final-condes = 'New'.
elseif gt_mat-type = 'B'.
gt_final-condes ='Block'.
append gt_final.
clear gt_final.
ENDIF.
ENDLOOP.
Also make sure the case of the value in gt_mat-type matches with the condition
Regards,
Vikranth
‎2009 Sep 14 11:45 AM
Hi Shree,
The code provided by you looks good. It should work.
Please try condensing the gt_mat-type field using CONDENSE statement (before using it in case statement).
Also check the type of the field gt_mat-type. If it is not CHAR, then make it CHAR.
Hope it helps.
Regards,
Raveesh
Edited by: raveesh saurabh on Sep 14, 2009 12:47 PM