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: 

Purchase order field only displays 4 characters in my abap report

0 Kudos
296

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.

5 REPLIES 5

Sandra_Rossi
Active Contributor
240

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

0 Kudos
240

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.

0 Kudos
240

zubair sultan Please ask another question with same level of details.

former_member213437
Active Participant
0 Kudos
240
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.

former_member1716
Active Contributor
0 Kudos
240

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!