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: 

Inserting fields from 1 internal table into another internal table

Former Member
0 Kudos

Hi all,

I just started my first job and i'm asked to do ABAP. I've been assigned to develop my first ever ABAP program with no prior experience and manuals. I've been relying on the F1 key entirely. I hope i am doing fine. Anyway, my program has the following criteria:

1) to insert the Actual Delivery Date (BUDAT) from the WTAB internal table into the ITAB internal table and make it appear in the report. Have been unsuccessful in this matter. Tried LOOP AT WTAB, MODIFY ITAB ..., ENDLOOP but for some reason, only zeros appear.

Here's what i have done so far:

REPORT ZLPUPO100 NO STANDARD PAGE HEADING LINE-SIZE 86.

TABLES: EKKO,

EKPO,

EKBE,

EKET.

DATA: BEGIN OF ITAB OCCURS 0,

EBELN LIKE EKKO-EBELN, "PO Number

EBELP LIKE EKPO-EBELP, "Item Number

EINDT LIKE EKET-EINDT, "Delivery Date in PO

BUDAT LIKE EKBE-BUDAT, "Actual Delivery Date

END OF ITAB.

DATA: BEGIN OF WTAB OCCURS 0,

EBELN LIKE EKBE-EBELN, "PO Number

EBELP LIKE EKBE-EBELP, "Item Number

  • EINDT LIKE EKET-EINDT, "Delivery Date in PO

BUDAT LIKE EKBE-BUDAT, "Actual Delivery Date

END OF WTAB.

&----


*& SELECTION-SCREEN

&----


SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:

I_WERKS FOR EKPO-WERKS, "PLANT

I_BUKRS FOR EKKO-BUKRS, "COMPANY CODE

I_EBELN FOR EKKO-EBELN, "PO NUMBER

I_LIFNR FOR EKKO-LIFNR, "VENDOR NUMBER

I_MATNR FOR EKPO-MATNR, "MATERIAL NUMBER

I_BEDAT FOR EKKO-BEDAT. "PO DATE

SELECTION-SCREEN END OF BLOCK 1.

SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE TEXT-002.

PARAMETERS: P_ONET RADIOBUTTON GROUP RFMT, "ON-TIME DELIVERY

P_ODUE RADIOBUTTON GROUP RFMT, "OVERDUE

P_ALLP RADIOBUTTON GROUP RFMT, "BOTH (SORT BY PO NO.)

P_ALLC RADIOBUTTON GROUP RFMT. "BOTH (SORT BY CATEGORY)

SELECTION-SCREEN END OF BLOCK 2.

&----


*& START-OF-SELECTION

&----


START-OF-SELECTION.

PERFORM SELECT_DATA.

END-OF-SELECTION.

&----


*& SELECT_DATA

&----


FORM SELECT_DATA.

*--> IF ON-TIME DELIVERY IS SELECTED

IF P_ONET EQ 'X'.

...

*--> IF OVERDUE DELIVERY IS SELECTED

ELSEIF P_ODUE EQ 'X'.

...

*--> IF BOTH IS SELECTED, SORT BY PO NUMBER

ELSEIF P_ALLP EQ 'X'.

SELECT AEBELN BEBELP C~EINDT

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM ( EKKO AS A

INNER JOIN EKPO AS B

ON BEBELN = AEBELN

INNER JOIN EKET AS C

ON CEBELN = BEBELN AND

CEBELP = BEBELP AND

C~ETENR = '1')

WHERE B~WERKS IN I_WERKS AND

B~LOEKZ = ' ' AND

A~BUKRS IN I_BUKRS AND

A~BSTYP = 'F' AND

A~EBELN IN I_EBELN AND

A~LIFNR IN I_LIFNR AND

B~MATNR IN I_MATNR AND

A~BEDAT IN I_BEDAT

ORDER BY AEBELN BEBELP.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

SELECT EBELN EBELP BUDAT

INTO CORRESPONDING FIELDS OF TABLE WTAB

FROM EKBE

WHERE EBELN IN I_EBELN AND

  • EBELP = ITAB-EBELP AND

VGABE = '1' AND

BEWTP = 'E'

ORDER BY EBELN EBELP.

FORMAT COLOR COL_POSITIVE.

ULINE.

WRITE: '|', 5 'PO No.',

14 '|', 16 'PO Item No.',

28 '|', 'PO Delivery Date',

47 '|', 'Actual Delivery',

65 '|', 'Overdue Days (+/-)',

86 '|'.

FORMAT COLOR COL-POSITIVE OFF.

ULINE.

NEW-LINE.

*--->> This is the part that is making me confused

LOOP AT WTAB.

MODIFY ITAB TRANSPORTING BUDAT

WHERE EBELN = WTAB-EBELN AND

EBELP = WTAB-EBELP.

ENDLOOP.

LOOP AT ITAB.

WRITE: '|', 3 ITAB-EBELN, "PO NO

14 '|', 19 ITAB-EBELP, "PO ITEM NO

28 '|', 33 ITAB-EINDT, "PO DELIVERY DATE

47 '|', 51 ITAB-BUDAT, "ACTUAL DELIVERY DATE

65 '|',

86 '|'.

NEW-LINE.

ENDLOOP.

ULINE.

*--> IF BOTH IS SELECTED, SORT BY CATEGORY (+/-)

ELSE.

...

ENDIF.

ENDFORM.

Any hints you could provide? i need this asap, as i have to deliver by the end of the week, i can't fail in my first task assigned to me, i'm still in my job probation period...eeek...i've read the forums on merging internal tables and i still don't know where i've gone wrong...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Change you code as following

 LOOP AT WTAB.
<b>move wtab-budat to itab-budat.</b>
MODIFY ITAB TRANSPORTING BUDAT
WHERE EBELN = WTAB-EBELN AND
EBELP = WTAB-EBELP.
ENDLOOP 

7 REPLIES 7

Former Member
0 Kudos

Change you code as following

 LOOP AT WTAB.
<b>move wtab-budat to itab-budat.</b>
MODIFY ITAB TRANSPORTING BUDAT
WHERE EBELN = WTAB-EBELN AND
EBELP = WTAB-EBELP.
ENDLOOP 

Former Member
0 Kudos

Hi Bernard - is your requirement to insert the delivery date into the internal table or do you have technical specs that say use EKBE-BUDAT. The reason I ask is that I don't think that EKBE-BUDAT is necessarily the delivery date. It's the posting date of the GR.

Also, a PO item may have more than one GR. Do you have any requirements on how to handle this case. If not, you can go to your functional/business person. (It might get you a bit more time).

Rob

Former Member
0 Kudos

thank you so much!!! i can't believe it, all it took was a single line of code.

Former Member
0 Kudos

Yes, using EKBE-BUDAT is part of the spec documentation that was given to me.

Now comes another part, i have to figure out a way to calculate the overdue days (which i have declared as V_OVERDUE) by using the dates in Actual Delivery Date (ITAB-BUDAT) - PO Delivery Date (ITAB-EINDT).

But at the same time, should the Actual Delivery Date (ITAB-BUDAT) appear as 00.00.0000 (no value), the output in V_OVERDUE should be blank (or '-').

I know that i can't directly use ITAB-BUDAT - ITAB-EINDT like i would in Microsoft SQL, because if i did that, all sort of funny things would appear in the output. Any comments on this?

0 Kudos

Here is how you can achieve it.


IF NOT itab-budat IS INITIAL.
*-- BUDAT has some date
  v_overdue = itab-budat - iatb-eindt.
ELSE.
*-- BUDAT has no proper date
  clear v_overdue.
ENDIF.

Your v_overdue has to be of type I(=integer).

Regards,

Srinivas

Former Member
0 Kudos

thank you, srinivas...

i actually managed to do it on my own, but after reading your codes, i used yours instead, its straight to the point...i did mine by declaring another internal table, which didn't really make alot of sense doing so when i come to think about it...

right now i am attempting to only display the results of V_OVERDUE that have negative values when the user selects the P_ONET radiobutton...anybody can tell me which is a better approach between using FIND or SEARCH on the V_OVERDUE field?

been reading the F1 documentation, so i'll start trying out on using SEARCH first...thanks for everyone's help!!

0 Kudos

oops, sorry...managed to figured it out...

a simple IF V_OVERDUE LE 0, then delete the ITAB would have done the trick...

don't know why i was looking at FIND and SEARCH...my biggie