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.
Showing results for 
Search instead for 
Did you mean: 

alv output ?

Former Member
0 Kudos


i want to display salesgroup(vkgrp) and description(bezei)in my alv output as one column.

Also it should be sorted such that the 1st character=3rd character in the values of salesgroup.

eg:- 10C-Salesgroup1




Here in this example ...10C and 12C should be sorted, and it should be outputed.


Active Contributor
0 Kudos

Hi Hari,

You can use the following logic to sort VKGRP first & then concatenate the descrition before moving it ot the ALV table for display.

report  zalvsort.

data: begin of itab1 occurs 0,
      vkgrp type vkgrp,
      end of itab1.

data:  begin of itab2 occurs 0,
       end of itab2.
itab1-vkgrp = '10C'.
append itab1.
itab1-vkgrp = '12D'.
append itab1.
itab1-vkgrp = '15E'.
append itab1.
itab1-vkgrp = '12C'.
append itab1.
loop at itab1.
  itab2-fld1 = itab1-vkgrp(1).
  itab2-fld2 = itab1-vkgrp+1(1).
  itab2-fld3 = itab1-vkgrp+2(1).
  append itab2.
sort itab2 by fld1 fld3.
loop at itab2.
  write:/ itab2-fld1,itab2-fld2,itab2-fld3.


Suresh Datti

0 Kudos

Hai suresh..

those are the entries in the table..

I just given the example.

can u give ex. using ALV.

Sorting should be done thru 1st char of sales group equal to 3rd char of sales group.

Former Member
0 Kudos

data:begin of it_final occurs 0,

vkgrp like ztab-vkgrp,

bezei like ztab-bezei,



end of it_final.

*these 2 fields should not be displayed in alv,only the cmbined field should be displayed

it_fieldcat-fieldname = 'VTREG'.

it_fieldcat-tech = 'X'.

append it_fieldcat.

it_fieldcat-fieldname = 'BEZEI'.

it_fieldcat-tech = 'X'.

append it_fieldcat.

it_fieldcat-fieldname = 'SORT'.

it_fieldcat-no_out = 'X'.

append it_fieldcat.

loop at it_final.

concatenate it_final-vkgrp it_final-bezei into it_combined separated by '-'.

concatenate it_final-vkprg0(1) it_final-vkprg2(1) into it_final-sort.

modify it_final index sy-tabix.


sort it_final by sort.

Message was edited by: chandrasekhar jagarlamudi

0 Kudos

Hai chandrasekhar..

in your logic..Can u plz tell me what actually these are mean

it_fieldcat-tech ?

it_fieldcat-no_out ?

0 Kudos

it_fieldcat-tech = 'X'

If this field is set, the relevant field is not displayed on the list and cannot be shown interactively. The field is only known in the field catalog. (For example, it must not be specified as a sorting criterion).

it_fieldcat-no_out = 'X'

If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid

0 Kudos

Thnx chandrasekhar.

I need this column to be sorted when the first character is equal to the third character of vkgrp.

In my is not like that.

This is from TVKGR table(VKGRP and BEZEI).

plz give me select query as well.

0 Kudos

pls clarify on 2 things

1. what is that first character ??

give an example what do u mean by first char = third char

2.from which table u want to get the field BEZEI

Message was edited by: chandrasekhar jagarlamudi

0 Kudos

Hi Chandrasekhar,

I think hee needs the sort oder to be like the code I posted earlier.. but the sorting to be done on the ALV..

may be a combination of what you & I posted will do the trick for him...


0 Kudos

1) I hav entries for vkgrp in the table tvkgr as

10C, 10D, 10F, 20R, 12C...

In this...10C and 12C are sorted because first character = 3rd character.

2)BEZEI is the description for the salesgroup(VKGRP).

I am picking salesgroup from TVKGR table.

In the TVKGR ., if i see the table entries., there we can find salesgroup and description values.

Actually these details are my first secondarylist details..I am also facing problem when i cllick on basic list...the corresponding details of this records are should displayed.

0 Kudos

do u mean first char of 10C = first char of 12C and

third char of 10C = third char of 12C

and sorting in the sense do u want to populate it_sort table in REUSE_ALV_LIST_DISPLAY or

just sort itab by fld1

Message was edited by: chandrasekhar jagarlamudi

0 Kudos

yes..sorting should be done as u said.and in grid display.