2019 Nov 14 10:49 AM
Hi Guys
Please can you assist me .I am new to abap. I have written a code but my purchase order field only outputs 4 characters but on the table purchase order numbers are longer than that.
Abap code written.
*&---------------------------------------------------------------------*
*& Report ZTYPES
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztypes line-size 132.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
bukrs TYPE ekpo-bukrs,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo, "work area (header line)
wa_ekpo1 LIKE LINE OF it_ekpo.
**************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
*Select data in itab
SELECT bukrs
ebelp
ebeln
FROM ekpo
INTO TABLE it_ekpo.
*Process data within itab using LOOP statement
LOOP AT it_ekpo INTO wa_ekpo.
WRITE: wa_ekpo-ebelp,wa_ekpo-bukrs,wa_ekpo-ebeln.
* processing......
ENDLOOP.
2019 Nov 14 10:53 AM
The order of columns in the SELECT must be the same as in the target data object, that's not the case right now !
See your current code, the order of fields is different:
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
bukrs TYPE ekpo-bukrs,
...
SELECT bukrs
ebelp
ebeln
2019 Nov 14 11:05 AM
thank you so much.
Please can you also assist me .how do I write only one row per line at the moment I am writing 5 rows per line when the report displayed.
2019 Nov 14 11:40 AM
zubair sultan Please ask another question with same level of details.
2019 Nov 14 11:44 AM
You can use write statement as below
*For heading before loop
WRITE:/01 'Purch. Item', 10 'Company', 20 'Purch. Order'.
*In Loop....
WRITE:/01 wa_ekpo-ebelp, 10 wa_ekpo-bukrs, 20 wa_ekpo-ebeln.
2019 Nov 14 11:52 AM
Hello zubair sultan,
The order in which the columns are declared and order in which the columns are called and order in which columns are written are all different.
Basically all these must be aligned, below code should help you along with placing only one entry in one line in the report.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
bukrs TYPE ekpo-bukrs,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo, "work area (header line)
wa_ekpo1 LIKE LINE OF it_ekpo.
**************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
*Select data in itab
SELECT ebeln
ebelp
bukrs
FROM ekpo
INTO TABLE it_ekpo.
*Process data within itab using LOOP statement
LOOP AT it_ekpo INTO wa_ekpo.
WRITE:/ wa_ekpo-ebeln ,wa_ekpo-ebeln, wa_ekpo-bukrs.
* processing......
ENDLOOP.
Regards!