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: 

How to pick up the CDHDR-CHANGE ID value, based on EBELN at where condition

Former Member
0 Kudos

TYPES: BEGIN OF TY_CDHDR,

OBJECTID TYPE CDHDR-OBJECTID,

USERNAME TYPE CDHDR-USERNAME,

UDATE TYPE CDHDR-UDATE,

END OF TY_CDHDR.

SELECT ebeln bukrs bsart aedat ernam lifnr ekorg

FROM ekko

INTO TABLE gt_ekko

WHERE ebeln IN s_ebeln

AND bsart IN s_bsart

AND bedat IN s_bedat

AND ernam IN s_ernam.

IF sy-subrc EQ 0.

SELECT ebeln ebelp matnr

FROM ekpo

INTO TABLE gt_ekpo

FOR ALL ENTRIES IN gt_ekko

WHERE ebeln EQ gt_ekko-ebeln

AND matnr IN s_matnr.

IF gt_ekpo[] IS NOT INITIAL.

SELECT ebeln ebelp etenr eindt menge

FROM eket

INTO TABLE gt_eket

FOR ALL ENTRIES IN gt_ekpo

WHERE ebeln EQ gt_ekpo-ebeln

AND ebelp EQ gt_ekpo-ebelp.

IF sy-subrc EQ 0.

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

WHERE changeid EQ gt_ekpo-ebeln.

This is the exsisting code where i am getting a dump. Can you guys help me in this.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

WHERE changeid EQ gt_ekpo-ebeln.

Instead of change id in query it shd be :-

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

WHERE OBJECTID EQ gt_ekpo-ebeln.

15 REPLIES 15

GauthamV
Active Contributor
0 Kudos

use this fm to convert ebeln before passing to cdhdr table.

CONVERSION_EXIT_ALPHA_INPUT

former_member188827
Active Contributor
0 Kudos

what exactly is the error message?

Former Member
0 Kudos

Actually there is no error message, the cdhdr-changeid is of 90 chars and ekpo-ebeln is of 10 that's why this error message is coming.

0 Kudos

Hi super3013,

Modifiy as below :

TYPES: BEGIN OF TY_CDHDR,
OBJECTID TYPE CDHDR-OBJECTID,
USERNAME TYPE CDHDR-USERNAME,
UDATE TYPE CDHDR-UDATE,
END OF TY_CDHDR. 

SELECT ebeln bukrs bsart aedat ernam lifnr ekorg
FROM ekko INTO TABLE gt_ekko
  WHERE ebeln IN s_ebeln
    AND bsart IN s_bsart
    AND bedat IN s_bedat
    AND ernam IN s_ernam.

IF NOT gt_ekko[] IS INITIAL.
SELECT ebeln ebelp matnr
FROM ekpo INTO TABLE gt_ekpo
FOR ALL ENTRIES IN gt_ekko
  WHERE ebeln EQ gt_ekko-ebeln
    AND matnr IN s_matnr.
ENDIF.  

IF gt_ekpo[] IS NOT INITIAL.
SELECT ebeln ebelp etenr eindt menge
FROM eket INTO TABLE gt_eket
FOR ALL ENTRIES IN gt_ekpo
  WHERE ebeln EQ gt_ekpo-ebeln
    AND ebelp EQ gt_ekpo-ebelp.
 
  
SELECT objectid username udate
FROM cdhdr
INTO TABLE gt_cdhdr
FOR ALL ENTRIES IN gt_ekpo  
*  WHERE changeid EQ gt_ekpo-ebeln.  
  WHERE CHANGENR EQ gt_ekpo-ebeln.    
ENDIF.

There is no changeid Field of 90 chars in table CDHDR (but we have OBJECTID - 90 Char)

There is a field CHANGENR which is of 10 chars make use of it (Document change number).

Former Member
0 Kudos

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

WHERE changeid EQ gt_ekpo-ebeln.

Instead of change id in query it shd be :-

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

WHERE OBJECTID EQ gt_ekpo-ebeln.

Former Member
0 Kudos

This function module (conversion_exit_alpha_input) is not helping me, as the select statement itself is failing.

0 Kudos

how are u getting CHANGEID field in this table???? i get OBJECTID.

Former Member
0 Kudos

sorry for the mistypo, The field name is objectid

Now i have tried with ,

select objectid username udate

from cdhdr

into table gt_cdhdr

where objectid eq gt_ekpo-ebeln.

The program is getting a dump.

Former Member
0 Kudos

If you use this like

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

for all entries in gt_ekpo

WHERE objectid eq gt_ekpo-ebeln.

it is getting an activation error the field objectid and gt_ekpo-ebeln

must be of same type & length.

Former Member
0 Kudos

SELECT objectid username udate

FROM cdhdr

INTO TABLE gt_cdhdr

for all entries in gt_ekpo

WHERE changenr eq gt_ekpo-ebeln.

this wont work, as the changenr is indicationg, the change document

number.

0 Kudos

My dear this is going to work as OBJECTID is the value of PURCHASE ORDER NO. that u are changing.

As u are coding for PO ammendment i guess, The OBJECTID field refers to the Purch. Order no. (EKKO-EBELN) that is changed or created. U can check in the table entries too.

I ran ur program its giving no dump after changing CHANGEID to OBJECTID .

0 Kudos

Hi super3013,

Now with the help of Functional ask for a PO number which is in EKKO, EKPO, EKET and in CDHDR.

And check in Table content values and see how the data is stored in CDHDR.

Then think of your select statement how you need to fetch data from CDHDR

Regards,

Suneel G

0 Kudos

Hi,

Use the below function modules to get the header or item changes for Purchase Orders.

CHANGEDOCUMENT_READ_HEADERS

CHANGEDOCUMENT_READ_HDRS_ONLY

CHANGEDOCUMENT_READ_POSITIONS

Thanks,

Purna

former_member205763
Active Contributor
0 Kudos

To read the changes of PO better use fm ME_CHANGES_READ

Former Member
0 Kudos

Hi,

call the fm: CONVERSION_EXIT_INPUT.

get the gt_ekpo-ebeln value : 0000007777(example)

select objectid

username

changeid

udate from cdhdr into table gt_cdhdr

where changeid eq gt_ekpo-ebeln.

Then u will get the data.

Regards,

Naveen M.