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: 

internal table

Former Member
0 Kudos
205

Since cdhrd is transparent and cdpos is pool table, I suppose I cannot cary out a join, then how do I get the following fields into an internal table record

chhrd-changenr

cdhrd-udate

cdhrd-utime

cdpos-fname

cdpos-value_new

cdpos_value_old

from cdhrd and cdpos for a given

object class

objact value

field name

Then I need to sord the records as follows

change doc no time date

01 5:30 19.05.2008

02 4:30 01.02.2008

03 2:00 01.10.2007

Then for the sorted records above I need to carry out the following

record no from_date from_time to_date to_time

01 19.05.2008 5:30 Today Now

02 01.02.2008 4:30 19.05.2008 5:30

03 01.10.2007 2:00 01.02.2008 4:30

04 .......................... 01.10.2007 2:00

It is like a series, where from_date in record 1 becomes to_date in record 2.

4 REPLIES 4

Former Member
0 Kudos
76

Hi..

You can collect data from CDHDR table in internal table then loop at CDHDR internal table. call function module CHANGEDOCUMENT_READ_POSITIONS. pass cdhdr-changenr to FM and get values from CDPOS.

check below logic.

SELECT objectid "Object value

changenr "Document change number

udate "Creation date of the change document

utime "Time changed

username "Name of the person responsible in change document

INTO TABLE lt_cdhdr

FROM cdhdr

WHERE condition.

LOOP AT lt_cdhdr INTO ls_cdhdr.

Calling FM to get values from CDPOS

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

changenumber = ls_cdhdr-changenr

TABLES

editpos_with_header = lt_cdred

EXCEPTIONS

no_position_found = 1

wrong_access_to_archive = 2

OTHERS = 3.

LOOP AT lt_cdred INTO ls_cdred.

*collect following information from ls_cdhdr & ls_cdred.

*chhrd-changenr

*cdhrd-udate

*cdhrd-utime

*cdpos-fname

*cdpos-value_new

*cdpos_value_old

ENDLOOP. "loop at lt_cdred

ENDLOOP. "loop at Lt_cdhdr

Regards,

N M Poojari.

Former Member
0 Kudos
76

Hi ,

You these following function modules to get the details in two internal tables.

CHANGEDOCUMENT_READ_HEADERS Change document: Read change document header

CHANGEDOCUMENT_READ_POSITIONS Change document: Read change document items

Then sort both by the required fileds and then loop across and assign from_date and to_date to next record by keeping a copy of earlier internal table and reading based on index.

Please reward if useful.

0 Kudos
76

I have to do this based on tablename-fieldname, hoe can I do it

Former Member
0 Kudos
76

Hi,

types: begin of ty_cdhdr,

objectclas type CDOBJECTCL,

objectid type CDOBJECTV,

changenr type CHANGENR,

udate type CDDATUM,

utime type CDUZEIT,

end of ty_cdhdr.

types: begi of ty_cdpos,

objectclas type CDOBJECTCL,

objectid type CDOBJECTV,

fname type FIELDNAME,

value_new type CDFLDVALN,

value_old type CDFLDVALO,

end of ty_cdpos.

types: begin of ty_final,

changenr type CHANGENR,

udate type CDDATUM,

utime type CDUZEIT,

fname type FIELDNAME,

value_new type CDFLDVALN,

value_old type CDFLDVALO,

end of ty_final.

data: i_cdhdr type table of ty_cdhdr,

i_cdpos type table of ty_cdpos,

i_final type table of ty_final,

w_cdhdr type ty_cdhdr,

w_cdpos type ty_cdpos,

w_final type ty_final.

parameters: p_objectclas type cdhdr-objectclas,

p_objectid type cdhdr-objectid,

p_fname type cdpos-fname.

Select OBJECTCLAS OBJECTID CHANGENR UDATE UTIME from cdhdr into table i_cdhdr where OBJECTCLAS = p_OBJECTCLAS and OBJECTID = p_OBJECTID.

Select FNAME OBJECTCLAS OBJECTID FNAME VALUE_NEW VALUE_OLD FROM CDPOS FOR ALL ENTRIES IN I_CDHDR WHERE OBJECTCLAS = I_CDHDR-OBJECTCLAS and OBJECTID = I_CDHDR-OBJECTID AND FNAME = p_fname.

loop at i_cdpos into w_cdpos.

read table i_cdhdr into w_cdhdr with key OBJECTCLAS = w_CDPOS-OBJECTCLAS OBJECTID = W_CDPOS-OBJECTID.

if sy-subrc = 0.

w_final-changenr = w_cdhdr-changenr.

w_final-udate = w_cdhdr-udate.

w_final-utime = w_cdhdr-utime.

w_final-fname = w_cdpos-fname.

w_final-value_new = w_cdhdr-value_new.

w_final-value_old = w_cdhdr-value_old.

append w_final to i_final.

endif.

endloop.

I think it is useful for you.

Reward if it is helpful for you.

Thanks & regards

Deepika