cancel
Showing results for 
Search instead for 
Did you mean: 

Repetitive structure In ABAP HR

Former Member
0 Kudos

hi all ,

Am getting syntax error for the code below. Am using

4.7 .its says "p0041-dar01" and "date" are type-incompatible.

however when i compile the same code in 4.6 its workin fine. here is the code..

&----


*& Report ZTEST_REP *

*& *

&----


*& *

*& *

&----


REPORT ZTEST_REP .

INFOTYPES 0041.

NODES : PERNR.

data : begin of date,

dar like pa0041-dar01 ,

dat like pa0041-dat01.

data : end of date.

START-OF-SELECTION.

GET PERNR.

DO 12 TIMES VARYING DATE

FROM P0041-DAR01

NEXT p0041-DAR02.

write : / date-dar ,

date-dat.

write : / date.

ENDDO.

END-OF-SELECTION.

can i know what is the exact problem ...

Thanks

senthil

Accepted Solutions (1)

Accepted Solutions (1)

sergey_korolev
Active Contributor
0 Kudos

You should do like this:

DO 12 TIMES 
  VARYING DATE-DAR FROM P0041-DAR01
                   NEXT p0041-DAR02
  VARYING DATE-DAT FROM P0041-DAT01
                   NEXT p0041-DAT02.

  write : / date-dar ,
  date-dat.

  write : / date.

ENDDO.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Senthil,

The date is a structure containing two date fields. The following piece of code expects the field DATE to be of type d.

DO 12 TIMES VARYING DATE

FROM P0041-DAR01

NEXT p0041-DAR02.

Try replacing->

ata : begin of date,

dar like pa0041-dar01 ,

dat like pa0041-dat01.

data : end of date.

with->

data: date type d.

and->

write date.

instead of->

write : / date-dar ,

date-dat.

write : / date.

Good luck!

Marcel

Former Member
0 Kudos

Hi vijay ,

This program will work since its using single field , if we use structure as a variable it won't . Let me know if there is an alternative and simple solution.

Thanks

Senthil

suresh_datti
Active Contributor
0 Kudos

Hi,

Why don't you use the following delivered function module?

HRGPBS_CLASS_GET_IT0041_DATE

Good Luck,

Suresh Datti

VijayasekarK
Active Participant
0 Kudos

Hi Senthil ,

Try ...this way...

DATA: BEGIN OF WORD,

ONE VALUE 'E',

TWO VALUE 'x',

THREE VALUE 'a',

FOUR VALUE 'm',

FIVE VALUE 'p',

SIX VALUE 'l',

SEVEN VALUE 'e',

EIGHT VALUE '!',

END OF WORD,

LETTER1, LETTER2.

DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE

VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR.

WRITE: LETTER1, LETTER2.

IF LETTER2 = '!'.

EXIT.

ENDIF.

ENDDO.

The resulting output is the character string

"E x a m p l e !".

Regards,

Vijay

ssimsekler
Active Contributor
0 Kudos

Hi Senthil

4.7 may apply a more strict check on the DO...VARYING statement.

i. Does the repeating block only contains darXX and datXX fields? If not, you should include all the fields.

ii. There should be at least 12 blocks.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>