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: 

Hi Amit Mittal

Former Member
0 Kudos

Hi ,

I want to display all content of CDHDR & CDPOS by custom BAPI.I didnt get the output. Can you please check my coding & correct it. its Urgent.

Tables: cdhdr,cdpos.

ranges : r_udate for cdhdr-udate. " Creation date of change document

data: ir_objectid like cdhdr-objectid.

Data: msgv1 like sy-msgv1,

msgv2 like sy-msgv2,

msgv3 like sy-msgv3,

msgv4 like sy-msgv4.

select distinct objectid into ir_objectid from cdhdr

where objectclas = 'KOSTL'

and udate in r_udate

and tcode eq transactioncode.

if sy-subrc <> 0.

delete it_cdhdr.

msgv1 = transactioncode.

msgv2 = datasize.

msgv3 = no_of_days_from.

msgv4 = no_of_days_to.

perform set_bapireturn

tables return

using 'I' 'E!' '024' msgv1 msgv2 msgv3 msgv4 '1'.

endif.

.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

OBJECTCLASS = 'KOSTL'

OBJECTID = ir_objectid

TABLES

I_CDHDR = it_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.

Endselect.

Loop at it_cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

CHANGENUMBER = it_cdhdr-CHANGENR

IMPORTING

HEADER = cdhdr

TABLES

EDITPOS = it_cdpos

  • EDITPOS_WITH_HEADER = it_cdhdr

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.

ENDFUNCTION.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi silviya,

1. there were a FEW problems with your code :

a) i have comented SQl which is not required.

b) in FM CHANGEDOCUMENT_READ_HEADERS

i have passed username = ''

(its required, so that all records come)

c) in that fm , date is also requierd

2. Copy paste my code in new program

and see in debug,

u will GET ALL RECORDS.

(ITS YOUR CODE ONLY, WITH MINOR MODIFICATIONS)

3.

REPORT zsampl_001 .

*TABLES: cdhdr,cdpos.

DATA : cdhdr LIKE TABLE OF cdhdr WITH HEADER LINE.

DATA : cdpos LIKE TABLE OF cdpos WITH HEADER LINE.

DATA : tcdshw LIKE TABLE OF cdshw WITH HEADER LINE,

tcdred LIKE TABLE OF cdred WITH HEADER LINE.

RANGES : r_udate FOR cdhdr-udate. " Creation date of change document

DATA: ir_objectid LIKE cdhdr-objectid.

DATA: msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4.

*SELECT DISTINCT objectid INTO ir_objectid FROM cdhdr

*WHERE objectclas = 'KOSTL'

*AND udate IN r_udate

*AND tcode EQ transactioncode.

.

  • IF sy-subrc <> 0.

  • DELETE it_cdhdr.

  • msgv1 = transactioncode.

  • msgv2 = datasize.

  • msgv3 = no_of_days_from.

  • msgv4 = no_of_days_to.

  • PERFORM set_bapireturn

  • TABLES return

  • USING 'I' 'E!' '024' msgv1 msgv2 msgv3 msgv4 '1'.

  • ENDIF.

  • .

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

date_of_change = '20040101'

objectclass = 'KOSTL'

  • objectid = ir_objectid

username = ''

TABLES

i_cdhdr = cdhdr

EXCEPTIONS

no_position_found = 1

OTHERS = 2.

*ENDSELECT.

LOOP AT cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

changenumber = cdhdr-changenr

  • IMPORTING

  • header = cdhdr

TABLES

editpos = tcdshw

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.

regards,

amit m.

22 REPLIES 22

Former Member
0 Kudos

Hi ,

Can you please set a break point at

"Loop at it_cdhdr." and check whether there are any entries in internal table IT_CDHDR.

Regards,

Lanka

0 Kudos

Hi Lanka,

I checked loop at it_cdhdr & there is no entries in it_cdhdr.can you help me in that coding.urgent

thanks & regards,

Silviya T

0 Kudos

Hi Silviya,

Please check CDHDR table with Objectclass "KOSTL" and Date range as you are specifying in your programming. And check is there are any records.

Lanka

0 Kudos

Hi ,

I want to display all content of CDHDR & CDPOS by custom BAPI.I didnt get the output. Can you please check my coding & correct it. its Urgent.

Tables: cdhdr,cdpos.

ranges : r_udate for cdhdr-udate. " Creation date of change document

data: ir_objectid like cdhdr-objectid.

Data: msgv1 like sy-msgv1,

msgv2 like sy-msgv2,

msgv3 like sy-msgv3,

msgv4 like sy-msgv4.

select distinct objectid into ir_objectid from cdhdr

where objectclas = 'KOSTL'

and udate in r_udate

and tcode eq transactioncode.

if sy-subrc <> 0.

delete it_cdhdr.

msgv1 = transactioncode.

msgv2 = datasize.

msgv3 = no_of_days_from.

msgv4 = no_of_days_to.

perform set_bapireturn

tables return

using 'I' 'E!' '024' msgv1 msgv2 msgv3 msgv4 '1'.

endif.

.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

OBJECTCLASS = 'KOSTL'

OBJECTID = ir_objectid

TABLES

I_CDHDR = it_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.

Endselect.

Loop at it_cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

CHANGENUMBER = it_cdhdr-CHANGENR

IMPORTING

HEADER = cdhdr

TABLES

EDITPOS = it_cdpos

  • EDITPOS_WITH_HEADER = it_cdhdr

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.

ENDFUNCTION.

0 Kudos

Hi Silvia,

try this :

Tables: cdhdr,cdpos.

ranges : r_udate for cdhdr-udate. " Creation date of change document

data: ir_objectid like cdhdr-objectid.

Data : begin of iT_objectid occurs 0,

objectid like cdhdr-objectid,

CHANGENR like cdhdr-CHANGENR,

end of iT_objectid .

Data: msgv1 like sy-msgv1,

msgv2 like sy-msgv2,

msgv3 like sy-msgv3,

msgv4 like sy-msgv4.

select * from CDHDR into corresponding fields of table iT_objectid

where objectclas = 'KOSTL'

and udate in r_udate

and tcode eq TRANSACTIONCODE.

If not iT_objectid[] is initial.

Loop at iT_objectid .

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

CHANGENUMBER = iT_objectid-CHANGENR

IMPORTING

HEADER = cdhdr

TABLES

EDITPOS = it_cdpos

  • EDITPOS_WITH_HEADER = it_cdhdr

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.

endif.

Regards,

Lanka

0 Kudos

Hi Sliviya,

are you sure you have value in <b>ir_objectid</b>

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
EXPORTING
OBJECTCLASS = 'KOSTL'
<b>OBJECTID = ir_objectid</b>
TABLES
I_CDHDR = it_cdhdr
EXCEPTIONS
NO_POSITION_FOUND = 1
OTHERS = 2

check it in debugging..

Regards

Vijay

0 Kudos

Silviya,

First, you do not need to check sys-subrc inside the SELECT ... ENDSELECT loop as you will enter the loop only if you found a record. The sy-subrc check should be outside the ENDSELECT. Once you do that, check in debugging, if sy-subrc is zero or not. I think your problem may be in the select statement itself. Check your input for transaction code and also check if you have any entries in the table for KOSTL without giving any other values.

Srinivas

Former Member
0 Kudos

Hi silviya,

1. there were a FEW problems with your code :

a) i have comented SQl which is not required.

b) in FM CHANGEDOCUMENT_READ_HEADERS

i have passed username = ''

(its required, so that all records come)

c) in that fm , date is also requierd

2. Copy paste my code in new program

and see in debug,

u will GET ALL RECORDS.

(ITS YOUR CODE ONLY, WITH MINOR MODIFICATIONS)

3.

REPORT zsampl_001 .

*TABLES: cdhdr,cdpos.

DATA : cdhdr LIKE TABLE OF cdhdr WITH HEADER LINE.

DATA : cdpos LIKE TABLE OF cdpos WITH HEADER LINE.

DATA : tcdshw LIKE TABLE OF cdshw WITH HEADER LINE,

tcdred LIKE TABLE OF cdred WITH HEADER LINE.

RANGES : r_udate FOR cdhdr-udate. " Creation date of change document

DATA: ir_objectid LIKE cdhdr-objectid.

DATA: msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4.

*SELECT DISTINCT objectid INTO ir_objectid FROM cdhdr

*WHERE objectclas = 'KOSTL'

*AND udate IN r_udate

*AND tcode EQ transactioncode.

.

  • IF sy-subrc <> 0.

  • DELETE it_cdhdr.

  • msgv1 = transactioncode.

  • msgv2 = datasize.

  • msgv3 = no_of_days_from.

  • msgv4 = no_of_days_to.

  • PERFORM set_bapireturn

  • TABLES return

  • USING 'I' 'E!' '024' msgv1 msgv2 msgv3 msgv4 '1'.

  • ENDIF.

  • .

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

date_of_change = '20040101'

objectclass = 'KOSTL'

  • objectid = ir_objectid

username = ''

TABLES

i_cdhdr = cdhdr

EXCEPTIONS

no_position_found = 1

OTHERS = 2.

*ENDSELECT.

LOOP AT cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

changenumber = cdhdr-changenr

  • IMPORTING

  • header = cdhdr

TABLES

editpos = tcdshw

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.

regards,

amit m.

0 Kudos

Use CHANGEDOCUMENT_READ function module instead.

0 Kudos

Hi Amit,

while debugging i am getting values. when i executing i am not getting values.please check import,export parametres & the tables in this coding as below. let me know the correction.

Thanks,

Silviya

*"----


""Local interface:

*" IMPORTING

*" VALUE(TRANSACTIONCODE) LIKE ZBAPI_STRUCT-TCODE

*" VALUE(DATASIZE) LIKE ZBAPI_STRUCT-OBJECTID OPTIONAL

*" VALUE(NO_OF_DAYS_FROM) LIKE ZBAPI_STRUCT-UDATE OPTIONAL

*" VALUE(NO_OF_DAYS_TO) LIKE ZBAPI_STRUCT-UDATE OPTIONAL

*" TABLES

*" IT_CDHDR STRUCTURE CDHDR

*" IT_CDPOS STRUCTURE CDPOS

*" RETURN STRUCTURE BAPIRET1

*"----


DATA : cdhdr LIKE TABLE OF cdhdr WITH HEADER LINE.

DATA : cdpos LIKE TABLE OF cdpos WITH HEADER LINE.

DATA : tcdshw LIKE TABLE OF cdshw WITH HEADER LINE,

tcdred LIKE TABLE OF cdred WITH HEADER LINE.

RANGES : r_udate FOR cdhdr-udate. " Creation date of change document

DATA: ir_objectid LIKE cdhdr-objectid.

DATA: msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4.

*SELECT DISTINCT objectid INTO ir_objectid FROM cdhdr

*WHERE objectclas = 'KOSTL'

*AND udate IN r_udate

*AND tcode EQ transactioncode.

.

  • IF sy-subrc <> 0.

  • DELETE it_cdhdr.

  • msgv1 = transactioncode.

  • msgv2 = datasize.

  • msgv3 = no_of_days_from.

  • msgv4 = no_of_days_to.

  • PERFORM set_bapireturn

  • TABLES return

  • USING 'I' 'E!' '024' msgv1 msgv2 msgv3 msgv4 '1'.

  • ENDIF.

  • .

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

date_of_change = '20040101'

objectclass = 'KOSTL'

  • objectid = ir_objectid

username = ''

TABLES

i_cdhdr = cdhdr

EXCEPTIONS

no_position_found = 1

OTHERS = 2.

*ENDSELECT.

LOOP AT cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

EXPORTING

changenumber = cdhdr-changenr

  • IMPORTING

  • header = cdhdr

TABLES

editpos = tcdshw

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.

ENDFUNCTION.

0 Kudos

hi silviya,

1. while debugging i am getting values. when i executing i am not getting values

What i understand is that

u are CREATING a new FM

which will take some parameters

as input and return

the change document records.

2. If im correct,

then in the FM,

TABLES parameter,

pass CDHDR,

AND tcdshw (cdpos is not required)

and use the same variable names

which have been passed.

regards,

amit m.

0 Kudos

Hi Amit,

1 pass CDHDR,

AND tcdshw (cdpos is not required)

2. i have changed the table parameters as u mentioned above.its working.but whenever i am executing it is showing same output for different input values.no changes in output whatever may be the input.

3.i should select the change records which fall with in NO_OF_DAYS_FROM and NO_OF_DAYS_to & Tcode.

4. how can i proceed .. let me know the steps.

*"----


""Local interface:

*" IMPORTING

*" VALUE(TRANSACTIONCODE) LIKE ZBAPI_STRUCT-TCODE

*" VALUE(DATASIZE) LIKE ZBAPI_STRUCT-OBJECTID OPTIONAL

*" VALUE(NO_OF_DAYS_FROM) LIKE ZBAPI_STRUCT-UDATE OPTIONAL

*" VALUE(NO_OF_DAYS_TO) LIKE ZBAPI_STRUCT-UDATE OPTIONAL

*" TABLES

*" CDHDR STRUCTURE CDHDR

*" TCDSHW STRUCTURE CDSHW

*" RETURN STRUCTURE BAPIRET1

*"----


Thanks & regards,

Silviya T

0 Kudos

hi silviya,

1. The reason is bcos

the program code

does not USE/FILTER

from the input parameters of the FM

(initially i was not knowing

that u are doing this for FM,

i thought u were just creating a normal Z program)

2. As i see,

the FM is passed

a) object it

b) date

3. So in the first FM, CHANGEDOCUMENT_READ_HEADERS

u can set date the /pass the date parameter

date_of_change = (variable from FM parameter)

OBJECTID = (variable from FM)

4. If u do this,

the filteration will happen at the FM level itself.

(no need to use any separte sql)

3.

should select the change records which fall with in NO_OF_DAYS_FROM and NO_OF_DAYS_to & Tcode.

a) for this FM, tcode is not required.

b) From and to date , u can utilise the parameters

of the FM

DATE_OF_CHANGE (From-change date for search)

DATE_UNTIL (To-change date for search)

For this use another variable

like this

newdate = no_of_days_from + no_of_days.

5. i hope u understood.

Its just basic filteration in the code.

regards,

amit m.

0 Kudos

Hi Amit,

I have passed the import parameters (objectid as datsize, DATE_OF_CHANGE as no_of_days_from,DATE_UNTIL as no_of_days_to) into the FM like this.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

DATE_OF_CHANGE = no_of_days_from

OBJECTCLASS = 'KOSTL'

OBJECTID = datasize

DATE_UNTIL = no_of_days_to

TABLES

I_CDHDR = cdhdr

EXCEPTIONS

NO_POSITION_FOUND = 1

OTHERS = 4

.

But there is no output.

0 Kudos

Hi again,

1.

DATE_OF_CHANGE = no_of_days_from

DATE_UNTIL = no_of_days_to

Make sure both are DATES.

2.

OBJECTID = datasize

Make sure this has a valid value.

3. First try with hardcode value :

(valid values, one by one)

and check.

regards,

amit m.

0 Kudos

Hi Amit,

A. i have used the domain "DATUM" for getting date in import parameters NO_OF_DAYS_FROM & NO_OF_DAYS_to.that are date.is it correct?

B. i hv checked the FM by hard coding like this. But no output.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

DATE_OF_CHANGE = '19940101'

OBJECTCLASS = 'KOSTL'

OBJECTID = '10000000004210'

DATE_UNTIL = '20030101'

TABLES

I_CDHDR = cdhdr

EXCEPTIONS

NO_POSITION_FOUND = 1

OTHERS = 4

please help me.

Thanks,

Silviya T

0 Kudos

Hi again,

1. VERY IMPORTANT

pass this also. (as it is)

USERNAME = ''

2. It means,

that show records of ALL USERS.

(by default it is the logged on user)

3. when we give ''

it means all users.

4. DO THIS

and it WILL WORK.

regards,

amit m.

0 Kudos

Hi Amit,

It is working Fine. I have created BAPI "XYZ".

What is the use of FM RFC_ABAP_INSTALL_AND_RUN?

i want to display output of custom BAPI "XYZ" while executing RFC_ABAP_INSTALL_AND_RUN.

Is it possible ? How we can do?

Thanks & regards

Silviya T

0 Kudos

Hi silviya,

1. RFC_ABAP_INSTALL_AND_RUN

This is very dangerous FM.

2. It is used to CREATE a new program

where we provide the source code to it

in the form of internal table.

3.

I want to display output of custom BAPI "XYZ

What do u want to display ?

U can display a ALV from the FM itself.

or u can display the data from

the calling program itself

after fetching the info from the FM.

regards,

amit m.

0 Kudos

Hi,

I want to display the output of Custom BAPI "XYZ"

in FM table parameter "WRITES" of FM RFC_ABAP_INSTALL_AND_RUN.

whenever i am executing FM RFC_ABAP_INSTALL_AND_RUN,

it should display the output of BAPI "XYZ" in its WRITES table parameter.

Is it possible ? how we can Do?

Thanks & regards,

Silviya T

0 Kudos

Hi experts,

I want to display the output content of Custom BAPI "XXX" in Table parameter " WRITES" of FM RFC_ABAP_INSTALL_AND_RUN.

whenever we execute FM RFC_ABAP_INSTALL_AND_RUN,

its table parameter "WRITES" should show the output content of BAPI "XXX".

can we do like this? How ? Let me know the details.

Thanks,

Silviya T

Former Member
0 Kudos

Hi,

Use function module CHANGEDOCUMENT_READ which reads change pointer header and item values.

Refer the program RMCLAEBL which would help you a lot.

Thank you.

Regards,

Karun M