Application Development 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: 

problem in loop

Former Member
0 Kudos

Hi Experts....

I have my final table called it_final2

in my final table i jus want to show a status colum

as msg text1 or text2.

Below coding is for my final loop.....

i need to insert the coding for status which is as

if ( wa_bseg-hkont  = '0000207500' or  wa_bseg-hkont  = '0000207550' or wa_bseg-hkont  = '0000207555' ) and ( wa_bseg-augdt EQ '00000000' ).
wa_bseg-msg = 'text1'.
 when ( wa_bseg-hkont  = '0000207500' or  wa_bseg-hkont  = '0000207550' or wa_bseg-hkont  = '0000207555' ) and wa_bseg-augdt NE '00000000'
 wa_bseg-msg = 'text2'.
endif.

but now the problem is .....

either only one condition is getting satisfied like iam gettin only text1 and the else part not getting satisfied

and even in the first condition even if augdt EQ '00000000' it is not displaying the text1 msg.....

wat alteration to be made ....pls help....

thankx in advance

Rachel

LOOP AT it_bseg2 INTO wa_bseg.
 IF   wa_bseg-s_tax IS INITIAL AND  wa_bseg-ecess IS INITIAL  AND wa_bseg-hcess IS INITIAL.
        DELETE it_bseg2 WHERE belnr = wa_bseg-belnr.
      ELSE.
        w_t_amt = wa_bseg-t_p_amt + wa_bseg-s_tax + wa_bseg-ecess + wa_bseg-hcess.
        READ TABLE it_pos INTO it_pos WITH KEY belnr = wa_bseg-belnr.
        IF sy-subrc EQ 0.
          wa_bseg-blart = it_pos-blart.
       
          DATA: w_dat3 TYPE bseg-augdt.
          w_dat3 = wa_bseg-augdt.
          WRITE w_dat3+4(2) TO wa_bseg-monat1.

          IF wa_bseg-augdt IS NOT INITIAL.
            IF ( wa_bseg-monat1 >= 04 ) AND ( wa_bseg-monat1 <= 12 ).
              wa_bseg-monat1 = wa_bseg-monat1 - 03.
            ELSE.
              wa_bseg-monat1 = wa_bseg-monat1 + 09.
            ENDIF.
          ENDIF.
          MODIFY it_bseg2 FROM wa_bseg TRANSPORTING budat blart bldat xblnr monat monat1  .
        ENDIF.

        IF so_lifnr IS INITIAL.
          READ TABLE it_lifnr INTO wa_bseg WITH KEY belnr = wa_bseg-belnr.
          IF sy-subrc EQ 0.
            READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bseg-lifnr.
            IF sy-subrc EQ 0.
 CONCATENATE wa_lfa1-name1 wa_lfa1-name2  INTO wa_bseg-name SEPARATED BY space.

              READ TABLE it_regio WITH KEY bland = wa_lfa1-regio .

              wa_bseg-bezei = it_regio-bezei .
            
   MODIFY it_bseg2 FROM wa_bseg TRANSPORTING lifnr name bezei ort01 j_1isern  .
            ENDIF.

            MODIFY it_bseg2 FROM wa_bseg TRANSPORTING t_amt  .
          ENDIF.
        ENDIF.

        READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bseg-lifnr.
        IF sy-subrc EQ 0.
          CONCATENATE wa_lfa1-name1 wa_lfa1-name2  INTO wa_bseg-name.
          CONDENSE wa_bseg-name .

          READ TABLE  it_regio WITH KEY bland = wa_lfa1-regio .
          wa_bseg-bezei     =  it_regio-bezei .
         MODIFY it_bseg2 FROM wa_bseg TRANSPORTING name bezei ort01 j_1isern  .
        ENDIF.
      ENDIF.

      IF so_lifnr-low IS INITIAL.
        IF wa_bseg-blart = 'KH'.

       ENDIF.
   MODIFY it_bseg2 FROM wa_bseg TRANSPORTING t_amt   .
    ENDLOOP.

  ENDIF.

19 REPLIES 19

Former Member
0 Kudos

Hi

It can be posted only a certain number of abap code lines, u should split your code in several post.

Max

0 Kudos

thnx

0 Kudos

if you post the code in <> it will be much more legible and it will e easier for people to help you !

Former Member
0 Kudos

as msg text1 or text2.

Below coding is for my final loop.....

i need to insert the coding for status which is as

if ( wa_bseg-hkont  = '0000207500' or  wa_bseg-hkont  = '0000207550' or wa_bseg-hkont  = '0000207555' ) and ( wa_bseg-augdt EQ '00000000' ).
wa_bseg-msg = 'text1'.
 when ( wa_bseg-hkont  = '0000207500' or  wa_bseg-hkont  = '0000207550' or wa_bseg-hkont  = '0000207555' ) and wa_bseg-augdt NE '00000000'
 wa_bseg-msg = 'text2'.
endif.

but now the problem is .....

either only one condition is getting satisfied like iam gettin only text1 and the else part not getting satisfied

and even in the first condition even if augdt EQ '00000000' it is not displaying the text1 msg.....

wat alteration to be made ....pls help....

thankx in advance

Rachel

0 Kudos

case wa_bseg-hkont.
	when: '0000207500' or '0000207550' or '0000207555'.
   if wa_bseg-augdt is initial.
     wa_bseg-msg = 'text1'.
   else.
     wa_bseg-msg = 'text2'.
   endif.
endcase.

Edited by: Keshu Thekkillam on Jul 23, 2009 2:56 PM

0 Kudos

Rachel,

Its better to breakup conditions into two parts first as follows:

if wa_bseg-augdt is initial.

if ( wa_bseg-hkont = '0000207500' or wa_bseg-hkont = '0000207550' or wa_bseg-hkont = '0000207555' )

wa_bseg-msg = 'text1'.

else.

wa_bseg-msg = 'text2'.

endif.

endif.

Then proceed for next step.

regds,

Anil

Edited by: Anil Katoch on Jul 23, 2009 11:42 AM

Edited by: Anil Katoch on Jul 23, 2009 11:44 AM

0 Kudos

Hello Rachel ,

You have given two condition like the below one u2026

If (v1 = a or v2 = b or v3 = c) and (v4 eq d) .

Var1 = text1 .

Elseif (v1 = a or v2 = b or v3 = c) and (v4 ne d) .

Var1 = text2 .

Endif .

The logic you applied will always u2026.triggers only on condition ( Reason either v4 could be d or not ) .

Now please specify what you want to do?

Thanks and Regads .

Priyank

0 Kudos

thanx a lot for your reply...

i already tried using case

but again the same problem which iam not

able to spot it out.....

the problem again iam facing is

for the given input

3 document number shud be as text2 and

rest as text1

but only ones the else is gettin satisfied

and even in that else that document number shud

be text1 but its satisfying else and displaying

text2.

hope iam not confusing ....

thanks again

0 Kudos

your are confusing need a example with records

0 Kudos

yes priyank wat is said is right

even i want the same ouput as

if v4 = d the fist msg

else

second msg....

but still the same problem exist

0 Kudos
BELNR      GJAHR BUZEI BUZID AUGDT      AUGCP      HKONT                                                                                
1600000317 2008  001         09.05.2009 09.05.2009 0000200020        
 1600000317 2008  002         00.00.0000 00.00.0000 0000406602        
 1600000317 2008  003         00.00.0000 00.00.0000 0000207500        
 1600000317 2008  004         00.00.0000 00.00.0000 0000207550        
 1600000317 2008  005         00.00.0000 00.00.0000 0000207555

in this i shud get the msg as text1

ie

when: '0000207500' or '0000207550' or '0000207555'.
   if wa_bseg-augdt is initial.
     wa_bseg-msg = 'text1'.

but instead my else part is getting satisfied and iam getting text2

next problem is

BELNR      GJAHR BUZEI BUZID AUGDT      AUGCP      HKONT                                                                                
1900000124 2008  001         00.00.0000 00.00.0000 0000302700                 
  1900000124 2008  002         00.00.0000 00.00.0000 0000411900                 
  1900000124 2008  003         31.03.2009 16.07.2009 0000207500                 
  1900000124 2008  004         00.00.0000 00.00.0000 0000207550                 
  1900000124 2008  005         00.00.0000 00.00.0000 0000207555                 
  1900000124 2008  006         00.00.0000 00.00.0000 0000301800

in this case text 2 shud come but status displayed blank .....

0 Kudos

Hi Frn,

Please check the data type of wa_bseg-augdt

If it is num than just give 0 .

If it is char8 than u201800000000u2019 (8 zero)

Thanks ..

Priyank

0 Kudos

You have to include line item impact as for same document you are having AUGDT value for both of the documents.

For first record, you are having AUGDT in First Line Item, while for second document you are having same for different line item.

plz check,

regds,

Anil

0 Kudos

AUGDT is in different format 00.00.0000.

data:pattern(10) type c value '00.00.0000'.

when: '0000207500' or '0000207550' or '0000207555'.

if wa_bseg-augdt = pattern

wa_bseg-msg = 'text1'.

else.

wa_bseg-msg = 'text2'.

endif.

endcase

0 Kudos

hello,

i think the data type of the augdat is of sy-datum (Dats) . whenever you gives '00000000' vaue to augdat ....it is treating it as initial .

test the below code

PARAMETERS: p_file TYPE rlgrap-filename.

data : v_date type sy-datum.

v_date = '00000000' .

break-point .

if v_date is INITIAL .

write: 'hi .' .

elseif v_date = '00000000' .

write: 'hello .' .

endif .

Thanks ..

Priyank

0 Kudos

hi thanks

i tried all the option while debuggin came to know that

its not the format of date but the problem comes in date field

BELNR      GJAHR BUZEI BUZID AUGDT      AUGCP      HKONT       
                                                               
1900000124 2008  001         00.00.0000 00.00.0000 0000302700  
1900000124 2008  002         00.00.0000 00.00.0000 0000411900  
1900000124 2008  003         31.03.2009 16.07.2009 0000207500  
1900000124 2008  004         00.00.0000 00.00.0000 0000207550  
1900000124 2008  005         00.00.0000 00.00.0000 0000207555  
1900000124 2008  006         00.00.0000 00.00.0000 0000301800  
1900000125 2008  001         00.00.0000 00.00.0000 0000302700  
1900000125 2008  002         00.00.0000 00.00.0000 0000411900  
1900000125 2008  003         31.03.2009 17.07.2009 0000207500  
1900000125 2008  004         00.00.0000 00.00.0000 0000207550  
1900000125 2008  005         00.00.0000 00.00.0000 0000207555  
1900000125 2008  006         00.00.0000 00.00.0000 0000301800

for example in the above case

1900000125 -


> right but not printed

207500

20090331

text2

19000000124 -


> it has date but taking 207555 g/l and date as blank and notprinted

207555

00000000

text1

but both not displayed in output

any idea abt the issue

thanx again

0 Kudos

but both not displayed in output

any idea abt the issue

your thread is going to a broader range ... why its not prinitng .. how can we answer .. just check the code..

The problem you have highlighted is because of the type format of date field .. if that is changed then the conditions will work ..

0 Kudos

fine i will check

thanx alot

iam stopping my thread here..

thanx everybody .....

Former Member
0 Kudos

part of my final loop coding

LOOP AT it_bseg2 INTO wa_bseg.
 IF   wa_bseg-s_tax IS INITIAL AND  wa_bseg-ecess IS INITIAL  AND wa_bseg-hcess IS INITIAL.
        DELETE it_bseg2 WHERE belnr = wa_bseg-belnr.
      ELSE.
        w_t_amt = wa_bseg-t_p_amt + wa_bseg-s_tax + wa_bseg-ecess + wa_bseg-hcess.
        READ TABLE it_pos INTO it_pos WITH KEY belnr = wa_bseg-belnr.
        IF sy-subrc EQ 0.
          wa_bseg-blart = it_pos-blart.
       
          DATA: w_dat3 TYPE bseg-augdt.
          w_dat3 = wa_bseg-augdt.
          WRITE w_dat3+4(2) TO wa_bseg-monat1.

          IF wa_bseg-augdt IS NOT INITIAL.
            IF ( wa_bseg-monat1 >= 04 ) AND ( wa_bseg-monat1 <= 12 ).
              wa_bseg-monat1 = wa_bseg-monat1 - 03.
            ELSE.
              wa_bseg-monat1 = wa_bseg-monat1 + 09.
            ENDIF.
          ENDIF.
          MODIFY it_bseg2 FROM wa_bseg TRANSPORTING budat blart bldat xblnr monat monat1  .
        ENDIF.
ENDLOOP.