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: 

ITAB display prob

Former Member
0 Kudos

Hi,

I have data in internal table in bolow mentioned format:

EBELN EBELP MAT_DOC_NO INV_DOC_NO

4500099999 10 5000001502

4500099999 10 5000001528

4500099999 10 5000001529

4500099999 10 5105601271

4500099999 10 5105601272

4500099999 20 5000001509

4500099999 20 5000001510

4500099999 20 5000001537

4500099999 30 5000001511

4500099999 30 5105601250

4500099999 30 5105601251

4500099999 40 5000001534

4500099999 40 5105601276

But I want to display like this...

EBELN EBELP MAT_DOC_NO INV_DOC_NO

4500099999 10 5000001502 5105601271

4500099999 10 5000001528 5105601272

4500099999 10 5000001529

4500099999 20 5000001509 5105601250

4500099999 20 5000001510 5105601251

4500099999 20 5000001537

4500099999 30 5000001511

4500099999 40 5000001534 5105601276

Means for mat doc and inv doc will not display in new line, in the same line it should display. If itab has more mat doc or inv doc in comparison with each other. Then in that case blank will display in other column....

In short, i want display my itab as above mentioned....

Pls reply...

i'm having the problem in putting the itab in correct format infact first itab the docs which starts from 51...these are under inv_doc column. INfact when i save this message, it saves under mat...infact these are ivnoice docs

Thanks,

Message was edited by:

Sal Khan

16 REPLIES 16

naimesh_patel
Active Contributor
0 Kudos

If you have a link between your mat_doc and inv_doc... than you can do it like this...

and delete invoices from the ITAB.


DELETE ITAB where doc_not_inv = 'X'.
Loop at itab.
read table itab_link with key mat_doc = itab-mat_doc.
if sy-subrc = 0.
itab-inv_doc = itab_link-inv_doc.
modify itab.
endif.

endloop.

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi,

I have a little confusion in your question. If your intrenal table has 4 fileds EBELB, EBELP MAT_DOC_NO and INV_DOC_NO, the data will be in four columns.

4500099999 10 5000001502 5105601271

4500099999 10 5000001528 5105601272

4500099999 10 5000001529

etc.

to print in the same use the below code:

Sort ITAB by EBELN EBELP.

Loop at ITAN.

write: / itab-ebeln, 10 itab-ebelp, 17 itab-MAT_DOC_NO, 28 itab-INV_DOC_NO

endloop.

Former Member
0 Kudos

Use the code button above to retain the structure of your table.

Do you have all this data in one internal table or two?

0 Kudos

See below,
I have only one itab, and the records formats are like this. requirement is not to display inv_doc_no for the same po line item in new row. But there are some case in which i have only one mat doc and many invoices...
EBELN	EBELP	MAT_DOC_NO	INV_DOC_NO
4500099999	10	5000001502	
4500099999	10	5000001528	
4500099999	10	5000001529	
4500099999	10		5105601271
4500099999	10		5105601272
4500099999	20	5000001509	
4500099999	20	5000001510	
4500099999	20	5000001537	
4500099999	30	5000001511	
4500099999	30		5105601250
4500099999	30		5105601251
4500099999	40	5000001534	
4500099999	40		5105601276

My final output should be like this..
EBELN	EBELP	MAT_DOC_NO	INV_DOC_NO
4500099999	10	5000001502	5105601271
4500099999	10	5000001528	5105601272
4500099999	10	5000001529	
4500099999	20	5000001509	5105601250
4500099999	20	5000001510	5105601251
4500099999	20	5000001537	
4500099999	30	5000001511	
4500099999	40	5000001534	5105601276


Hope you understand, pls suggest!!

Message was edited by:

Sal Khan

0 Kudos

Try this

data l_index type i.

LOOP AT itab INTO wa_itab1.

WRITE:/ <EBELN EBELP MAT_DOC_NO>

READ TABLE itab INTO wa_itab2 WITH KEY ebeln = wa_itab1-ebeln

ebelp = wa_itab1-ebelp.

IF sy-subrc = 0.

l_index = sy-tabix.

WRITE wa_itab1-INV_DOC_NO.

DELETE TABLE itab index l_index.

ENDIF.

ENDLOOP.

This is just rough logic, correct the syntaxes.

Regards,

Atish

0 Kudos

I dont want to write it, i want to put in same or some other internal table, bcoz i'm displaying the data in ALV grid, and i'm passing this itab to ALV grid.

Thanks,

0 Kudos

Do the same thing and move the data to other internal table. Just replace WRITE with assignment to the other variable.

Regards,

Atish

Former Member
0 Kudos

Declare another internal table of the same structure and do the following.

itab1 is your original table and itab2 is your new table.

SORT itab1 BY ebeln ebelp.
itab2[] = itab1[].
DELETE ADJACENT DUPLICATES FROM itab2 COMPARING ebeln ebelp.
LOOP AT itab2.
  WRITE:/ itab2-ebeln.
  LOOP AT itab1 WHERE ebeln = itab2-ebeln AND ebelp = itab2-ebelp.
    WRITE:/ itab1-ebelp.
    IF itab1-mat_doc_no IS NOT INITIAL.
   WRITE: itab1-mat_doc_no. "(give its position where it needs to start)
    ENDIF.
    IF itab1-inv_doc_no IS NOT INITIAL.
   WRITE: itab1-inv_doc_no. "(give its position where it needs to start)
    ENDIF.
  ENDLOOP.
ENDLOOP.

0 Kudos

I am sorry I saw your reply about not wanting to WRITE little late.

Do like this if you want to create and itab that you can pass it to ALV.

SORT itab1 BY ebeln ebelp.
itab2[] = itab1[].
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING ebeln ebelp.
LOOP AT itab1.
  LOOP AT itab2 WHERE ebeln = itab1-ebeln AND ebelp = itab1-ebelp.
    IF itab2-mat_doc_no IS NOT INITIAL.
      MOVE itab2-mat_doc_no TO itab1-mat_doc_no.
    ENDIF.
    IF itab2-inv_doc_no IS NOT INITIAL.
      MOVE itab2-inv_doc_no TO itab1-inv_doc_no.
    ENDIF.
  ENDLOOP.
  MODIFY itab1.
ENDLOOP.

0 Kudos

Adavi,

It did't work,,,in this case only 4 enteries are left in new itab, bcoz we delete the adjacent. But it should be 8. pls suggest

0 Kudos

Have you tried my code. It will work.

Regards,

Atish

0 Kudos

Why is your 5105601250 and 5105601251 appearing on line 20 in your output whereas they are for line 30 in your internal table?

0 Kudos

Ya u r right, these are for line items 30. But according to ur code, it left out with only 4 rows. but it should have nine....

0 Kudos

Atish, your code is not working, pls suggest. Its giving me blank itab.

0 Kudos

Just paste the code which you written using my logic. Will correct it

0 Kudos

This will work.

  itab2[] = itab1[].
  DELETE itab2 WHERE belnr IS INITIAL.
  LOOP AT itab1 WHERE mblnr IS NOT INITIAL.
    LOOP AT itab2 WHERE ebeln = itab1-ebeln
                    AND ebelp = itab1-ebelp.
      MOVE itab2-belnr TO itab1-belnr.
      DELETE itab2.
      DELETE itab1 WHERE belnr = itab2-belnr.
      EXIT.
    ENDLOOP.
    MODIFY itab1.
  ENDLOOP.