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: 

Select Logic

Former Member
0 Kudos

Hi,

Iam getting input PO, Company Code, Change date and changed user fields in selection screen. for this i have written this.

SELECT AEDAT EKGRP EBELN

BEDAT LIFNR WAERS

ERNAM FROM EKKO INTO TABLE GT_EKKO WHERE

EBELN IN SO_EBELN AND

BUKRS IN SO_BUKRS AND

EKGRP IN SO_EKGRP.

SELECT OBJECTID

USERNAME

UDATE FROM CDHDR INTO TABLE GT_HDR

FOR ALL ENTRIES IN GT_EKKO WHERE

OBJECTID EQ GT_EKKO-EBELN AND

OBJECTCLAS = 'EINKBELEG' AND

USERNAME IN SO_ERNAM AND

UDATE IN SO_ERDAT.

Problem is "OBJECTID" and "GT_EKKO-EBELN" does not have same length. how should i proceed.

Regards

Reddy

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this...

DATA: BEGIN OF ITAB_OBJECTID OCCURS 0,

OBJECTID LIKE CDHDR-OBJECTID,

END OF ITAB_OBJECTID.

LOOP AT GT_EKKO.

ITAB_OBJECTID-OBJECTID = GT_EKKO-EBELN.

APPEND ITAB_OBJECTID.

ENDLOOP.

IF NOT ITAB_OBJECTID[] IS INITIAL.

SELECT OBJECTID

USERNAME

UDATE FROM CDHDR INTO TABLE GT_HDR

FOR ALL ENTRIES IN ITAB_OBJECTID WHERE

OBJECTID EQ ITAB_OBJECTID-OBJECTID AND

OBJECTCLAS = 'EINKBELEG' AND

USERNAME IN SO_ERNAM AND

UDATE IN SO_ERDAT.

ENDIF.

Thanks,

Naren

3 REPLIES 3

Former Member
0 Kudos

Hi ,

You can use the offset in the where condition to match the object id and the ebeln. For example if the ebeln starts at 4 position and ends at 14 position i.e 10 charecters you can use the where condition as

SELECT OBJECTID

USERNAME

UDATE FROM CDHDR INTO TABLE GT_HDR

FOR ALL ENTRIES IN GT_EKKO WHERE

<b>OBJECTID+3(10) EQ GT_EKKO-EBELN AND</b>

OBJECTCLAS = 'EINKBELEG' AND

USERNAME IN SO_ERNAM AND

UDATE IN SO_ERDAT.

Hope this helps.

Former Member
0 Kudos

Hi,

Try this...

DATA: BEGIN OF ITAB_OBJECTID OCCURS 0,

OBJECTID LIKE CDHDR-OBJECTID,

END OF ITAB_OBJECTID.

LOOP AT GT_EKKO.

ITAB_OBJECTID-OBJECTID = GT_EKKO-EBELN.

APPEND ITAB_OBJECTID.

ENDLOOP.

IF NOT ITAB_OBJECTID[] IS INITIAL.

SELECT OBJECTID

USERNAME

UDATE FROM CDHDR INTO TABLE GT_HDR

FOR ALL ENTRIES IN ITAB_OBJECTID WHERE

OBJECTID EQ ITAB_OBJECTID-OBJECTID AND

OBJECTCLAS = 'EINKBELEG' AND

USERNAME IN SO_ERNAM AND

UDATE IN SO_ERDAT.

ENDIF.

Thanks,

Naren

Former Member
0 Kudos

Hi Reddy,

Its good to have the same sequence as in DB table using WHERE CLAUSE. And seems u r missing CHANGE NO from CDHDR (I assume u r going to get details from CDPOS also)

SELECT OBJECTCLAS OBJECTID CHANGENR USERNAME UDATE

FROM CDHDR INTO TABLE GT_HDR

FOR ALL ENTRIES IN GT_EKKO WHERE

OBJECTCLAS = 'EINKBELEG' AND

OBJECTID EQ GT_EKKO-EBELN AND

USERNAME IN SO_ERNAM AND

UDATE IN SO_ERDAT.

Are you not able to get data from CDHDR based on ur data?