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

Urgent Help

Former Member
0 Likes
1,161

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.here i want all data from CDPOS also.

while debugging i dont have any values in Tcdpos.

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.

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.here i want all data from CDPOS also.

while debugging i dont have any values in Tcdpos.

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.

7 REPLIES 7
Read only

Former Member
0 Likes
1,090

You are looping at CDHDR table and for each record you are getting items. But Items are getting replaced every loop pass.

Try this code

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.

{append lines of tcdpos to another internal table which will contain all items details.}

ENDLOOP.

To populate final details -

Loop at items table.

read header table.

Get all output fields populated.

endloop.

Message was edited by: Ashish Gundawar

Read only

Former Member
0 Likes
1,090

You have another post open with the same question. Can you please close this one as you have more responses in the other one?

Regards,

Srinivas

Read only

Former Member
0 Likes
1,090

Hello Silviya,

U can try using FM CHANGEDOCUMENT_READ which read from CDHDR and POS table and give u result in internal table which u can format as per ur req.

If not, in ur current code u are calling FM 'CHANGEDOCUMENT_READ_POSITIONS' within the loop for CDHDR and it is replacing the the contents in tcdred. So what u will c in this effectively is the last record.

what u need to do is

Data : tsave LIKE TABLE OF cdred WITH HEADER LINE.

clear tsave.

refresh t_save.

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.

append lines of tcdred to tsave.

clear tsave.

ENDLOOP.

later when u are looping through cdhdr u can use tsave to display the rest.

Read only

0 Likes
1,090

hi experts,

The program is hanging.No result. I have coded like the following.

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.

append lines of tcdpos to tcdpos1.

refresh tcdpos.

endloop.

loop at cdhdr.

struct1-OBJECTCLAS = cdhdr-OBJECTCLAS.

struct1-OBJECTID = cdhdr-OBJECTID.

  • struct1-KEYVALUE = w_kvalue.

struct1-CHANGENR = cdhdr-CHANGENR.

struct1-USERNAME = cdhdr-USERNAME.

struct1-UDATE = cdhdr-UDATE.

struct1-UTIME = cdhdr-UTIME.

struct1-TCODE = cdhdr-TCODE.

struct1-PLANCHNGNR = cdhdr-PLANCHNGNR.

struct1-ACT_CHNGNO = cdhdr-ACT_CHNGNO.

struct1-WAS_PLANND = cdhdr-WAS_PLANND.

struct1-CHANGE_IND = cdhdr-CHANGE_IND.

struct1-LANGU = cdhdr-LANGU.

struct1-VERSION = cdhdr-VERSION.

append struct1.

loop at tcdpos1.

struct2-TABNAME = Tcdpos1-TABNAME.

struct2-TABKEY = Tcdpos1-TABKEY.

struct2-FNAME = Tcdpos1-FNAME.

struct2-CHNGIND = Tcdpos1-CHNGIND.

struct2-TEXT_CASE = Tcdpos1-TEXT_CASE.

struct2-OUTLEN = Tcdpos1-OUTLEN.

struct2-F_OLD = Tcdpos1-F_OLD.

struct2-F_NEW = Tcdpos1-F_NEW.

struct2-KEYGUID = Tcdpos1-KEYGUID.

struct2-TABKEY254 = Tcdpos1-TABKEY254.

struct2-EXT_KEYLEN = Tcdpos1-EXT_KEYLEN.

append struct2.

endloop.

endloop.

Read only

0 Likes
1,090

HI Silviya Thomas

This code is to read change docs for PO.

in OBjectclass you need to fill the relavant OBJECTCLASS acc. to your reqirement.

var_objid = PONUMBER in this case.

*******************************

DATA: EDITPOS TYPE TABLE OF CDRED WITH HEADER LINE.



CALL FUNCTION 'CHANGEDOCUMENT_READ'
        EXPORTING
          DATE_OF_CHANGE             = '24.01.2006'
          OBJECTCLASS                = 'EINKBELEG'
          OBJECTID                   = VAR_OBJID
          TABLENAME                  = 'EKPO'
        TABLES
          EDITPOS                    = EDITPOS
        EXCEPTIONS
          NO_POSITION_FOUND          = 1
          WRONG_ACCESS_TO_ARCHIVE    = 2
          TIME_ZONE_CONVERSION_ERROR = 3
          OTHERS                     = 4.

NOW EDITPOS WILL CONTAIN THE MERGED DATA FROM COMBINATION OF

<b>CDHDR</b> AND <b>CDPOS</b>.

CHEERS,

VIJAY RAHEJA

Read only

Former Member
0 Likes
1,090

I would suggest u also include changenr field in the resultant table this will help u while u are looping against cdhdr table...

loop cdhdr.

.....

loop at tcdpos1 where changenr = cdhdr-changenr.

....

endloop.

endloop.

This will read through only for the realted change nr.

Read only

Lakshmant1
Active Contributor
0 Likes
1,090

Hi Silviya,

Have a look at standard reports

RC1CD100

RCS00120

RFTBST10

RFVWCD20

RSSCD100

RSSCD110

Hope this helps.

Thanks

Lakshman