Skip to Content
0
Former Member
Feb 24, 2006 at 02:14 AM

looping problem

15 Views

Hi Experts,

1. I want to display all content of CDHDR & CDPOS table.But i am getting all data from CDHDR table & only one record from CDPOS.

2. I want to display the output format like this

cdhdr(header)objectclasobjectid^ ...version

cdpos(Item)TabnameTabkey^...Ext_keylen.

eg:

cdhdrKOSTL10000000001000^3261...

cdposCSKSB090100000000010009999123119940101^....

cdhdrKOSTL100000000010222^2788....

cdposCSKSB090100000000010009922222222222^....

...

..

.....

3. Anyone help me to get this format.Please modify the following coding to get the exact result.

*"----


""Local interface:

*" IMPORTING

*" VALUE(TRANSCATIONCODE) LIKE ZBAPI_STRUCT-TCODE OPTIONAL

*" VALUE(DATASIZE) LIKE ZBAPI_STRUCT-OBJECTID OPTIONAL

*" VALUE(NO_OF_DAYS) LIKE ZBAPI_STRUCT-DAYS

*" VALUE(DELIMITOR) LIKE ZBAPI_STRUCT-DELIMI OPTIONAL

*" TABLES

*" OUTPUT STRUCTURE ZBAPI_OUTPUT

*"----


Data: CDHDR like table of CDHDR WITH HEADER LINE,

TCDPOS like table of CDSHW WITH HEADER LINE.

Data : tcdred LIKE TABLE OF cdred WITH HEADER LINE.

data: date_from TYPE sy-datum.

date_from = sy-datum - no_of_days.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

DATE_OF_CHANGE = date_from

OBJECTCLASS = 'KOSTL'

username = ''

DATE_UNTIL = sy-datum

TABLES

I_CDHDR = cdhdr

EXCEPTIONS

NO_POSITION_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

changenumber = cdhdr-changenr

TABLES

editpos = Tcdpos

editpos_with_header = tcdred

EXCEPTIONS

no_position_found = 4

OTHERS = 8.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

data: Len type i,

pos type i,

w_kvalue(15) type c,

objid like cdhdr-OBJECTID,

strlen type string.

Len = strlen( cdhdr-objectid ).

pos = Len - datasize.

w_kvalue = cdhdr-objectid+pos(datasize).

loop at cdhdr.

output-OBJECTCLAS = cdhdr-OBJECTCLAS.

output-OBJECTID = cdhdr-OBJECTID.

output-KEYVALUE = w_kvalue.

output-CHANGENR = cdhdr-CHANGENR.

output-USERNAME = cdhdr-USERNAME.

output-UDATE = cdhdr-UDATE.

output-UTIME = cdhdr-UTIME.

output-TCODE = cdhdr-TCODE.

output-PLANCHNGNR = cdhdr-PLANCHNGNR.

output-ACT_CHNGNO = cdhdr-ACT_CHNGNO.

output-WAS_PLANND = cdhdr-WAS_PLANND.

output-CHANGE_IND = cdhdr-CHANGE_IND.

output-LANGU = cdhdr-LANGU.

output-VERSION = cdhdr-VERSION.

output-TABNAME = Tcdpos-TABNAME.

output-TABKEY = Tcdpos-TABKEY.

output-FNAME = Tcdpos-FNAME.

output-CHNGIND = Tcdpos-CHNGIND.

output-TEXT_CASE = Tcdpos-TEXT_CASE.

output-OUTLEN = Tcdpos-OUTLEN.

output-F_OLD = Tcdpos-F_OLD.

output-F_NEW = Tcdpos-F_NEW.

output-KEYGUID = Tcdpos-KEYGUID.

output-TABKEY254 = Tcdpos-TABKEY254.

output-EXT_KEYLEN = Tcdpos-EXT_KEYLEN.

append output.

endloop.

ENDFUNCTION.