Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in IF Condition

Former Member
0 Likes
752

Hi all,

Here i have one form printing Program. which is used at a time of sales. i done this report and form but now one problem is occur In one " IF " condition. i done code which is show below



LOOP AT itab1.

    SELECT *
          from konv
          into TABLE it_konv
          where knumv = v_knumv.




LOOP AT IT_VBRP.
LOOP AT it_konv WHERE KPOSN = IT_VBRP-POSNR .
  IF IT_VBRP-VRKME = 'BUN'.
     IF it_konv-kschl = 'JIVP'.
          tax_vat = tax_vat + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'ZIVP'.
          tax_add = tax_add + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'JIVC'.
          tax_cst = tax_cst + it_konv-kwert.
     ENDIF.

  ELSEIF IT_VBRP-VRKME = 'KAR'.
    IF it_konv-kschl = 'JIVP'.
          tax_vat_K = tax_vat_K + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'ZIVP'.
          tax_add_K = tax_add_K + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'JIVC'.
          tax_cst_K = tax_cst_K + it_konv-kwert.
     ENDIF.
  ENDIF.

   ENDLOOP.
ENDLOOP.


   IF tax_vat <> ' '.
        tax = 4.
        tax1 = 1.
        tax_text = '(4+1)%'.
   ELSEIF tax_cst <> ' '.
      tax = 2.
      tax_text = '2%'.
   ENDIF.
 ENDLOOP.


here we have 2 sales option like Bunch and Carton so BUN for BANCH and KAR for CARTON.

in above code i got tax value in tax_text variable when sales done in "BUN" but when sales done in " KAR " this time value is null so not getting in form printing. and if i put conditionlike

  IF IT_VBRP-VRKME = 'BUN' or  IT_VBRP-VRKME = 'KAR'. 

then next condition is overwrite so output is getting wrong.

So please give me a solution how can i put condition with BUN and KAR with out effect of KAR condition ....

please kindly guide me for this issue .

Thanks in Advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
707

HI,

there is a conversion exit on vrfme

it_vbrp-vrkme = 'BUN'. and for BUN it remains same after or with conversion exit so it is working

it_vbrp-vrkme = 'KAR'. but for KAR it changes to CAR

so check with CAR.

Hi all,

Here i have one form printing Program. which is used at a time of sales. i done this report and form but now one problem is occur In one " IF " condition. i done code which is show below



LOOP AT itab1.

    SELECT *
          from konv
          into TABLE it_konv
          where knumv = v_knumv.




LOOP AT IT_VBRP.
LOOP AT it_konv WHERE KPOSN = IT_VBRP-POSNR .
  IF IT_VBRP-VRKME = 'BUN'.
     IF it_konv-kschl = 'JIVP'.
          tax_vat = tax_vat + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'ZIVP'.
          tax_add = tax_add + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'JIVC'.
          tax_cst = tax_cst + it_konv-kwert.
     ENDIF.

  ELSEIF IT_VBRP-VRKME = 'KAR'.
    IF it_konv-kschl = 'JIVP'.
          tax_vat_K = tax_vat_K + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'ZIVP'.
          tax_add_K = tax_add_K + it_konv-kwert.

     ENDIF.
     IF it_konv-kschl = 'JIVC'.
          tax_cst_K = tax_cst_K + it_konv-kwert.
     ENDIF.
  ENDIF.

   ENDLOOP.
ENDLOOP.


   IF tax_vat <> ' '.
        tax = 4.
        tax1 = 1.
        tax_text = '(4+1)%'.
   ELSEIF tax_cst <> ' '.
      tax = 2.
      tax_text = '2%'.
   ENDIF.
 ENDLOOP.


here we have 2 sales option like Bunch and Carton so BUN for BANCH and KAR for CARTON.

in above code i got tax value in tax_text variable when sales done in "BUN" but when sales done in " KAR " this time value is null so not getting in form printing. and if i put conditionlike

  IF IT_VBRP-VRKME = 'BUN' or  IT_VBRP-VRKME = 'KAR'. 

then next condition is overwrite so output is getting wrong.

So please give me a solution how can i put condition with BUN and KAR with out effect of KAR condition ....

please kindly guide me for this issue .

Thanks in Advance

5 REPLIES 5
Read only

Former Member
0 Likes
707

Hi,

Are you using work area seperatly?

Can you try below code?


  LOOP AT it_vbrp.
    READ TABLE it_konv INTO wa_konv WITH KEY  kposn = it_vbrp-posnr .
    IF it_vbrp-vrkme = 'BUN'.
      CASE it_konv-kschl.
          when = 'JIVP'.
          tax_vat = tax_vat + it_konv-kwert.

        WHEN 'ZIVP'.
          tax_add = tax_add + it_konv-kwert.

        WHEN  'JIVC'.
          tax_cst = tax_cst + it_konv-kwert.
      ENDCASE.
    ELSEIF it_vbrp-vrkme = 'KAR'.
      CASE it_konv-kschl.
        WHEN 'JIVP'.
          tax_vat_k = tax_vat_k + it_konv-kwert.

        WHEN  'ZIVP'.
          tax_add_k = tax_add_k + it_konv-kwert.

        WHEN  'JIVC'.
          tax_cst_k = tax_cst_k + it_konv-kwert.

        ENDIF.
      ENDLOOP.
    ENDLOOP

Regards,

Pravin

Read only

Sridharnekkanti
Active Participant
0 Likes
707

seems to be nothing wrong in your logic. Check any conversion exit is there for the filed VBRP-VRKME.

put break-point in your program and check the value of VBRP-VRKME at the time of Sales done with KAR.

Read only

Former Member
0 Likes
708

HI,

there is a conversion exit on vrfme

it_vbrp-vrkme = 'BUN'. and for BUN it remains same after or with conversion exit so it is working

it_vbrp-vrkme = 'KAR'. but for KAR it changes to CAR

so check with CAR.

Read only

Former Member
0 Likes
707

Hi chk with this code..

LOOP AT IT_VBRP.

LOOP AT it_konv WHERE KPOSN = IT_VBRP-POSNR .

call function 'CONVERSION_EXIT_CUNIT_INPUT'

exporting

input = IT_VBRP-VRKME

language = sy-langu

importing

output = IT_VBRP-VRKME

exceptions

unit_not_found = 1

others = 2.

IF IT_VBRP-VRKME = 'BUN'.

IF it_konv-kschl = 'JIVP'.

tax_vat = tax_vat + it_konv-kwert.

ENDIF.

IF it_konv-kschl = 'ZIVP'.

tax_add = tax_add + it_konv-kwert.

ENDIF.

IF it_konv-kschl = 'JIVC'.

tax_cst = tax_cst + it_konv-kwert.

ENDIF.

ELSEIF IT_VBRP-VRKME = 'KAR'.

IF it_konv-kschl = 'JIVP'.

tax_vat_K = tax_vat_K + it_konv-kwert.

ENDIF.

IF it_konv-kschl = 'ZIVP'.

tax_add_K = tax_add_K + it_konv-kwert.

ENDIF.

IF it_konv-kschl = 'JIVC'.

tax_cst_K = tax_cst_K + it_konv-kwert.

ENDIF.

ENDIF.

ENDLOOP.

ENDLOOP.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
707

What is the problem or error you are facing ?