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: 

SERIAL NUMBER IN ALV OUT-PUT LIST

Former Member
0 Kudos

Hi all.

i have a doubt in the ALV display.

i am using the function module REUSE_ALV_GRID_DISPLAY for the out put.I want to get the serail number as my first field in my out put list.I don't have any such fiels in my internal table.

through the function module,is it possibleto get the serialnumber.

is there any other alternatives to get it...

Can anybody help me out.

thanks in advance,

regards,

Venkat

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Venkat,

You will have to do that manually by adding a field to the table and updating the field with the data, there is no automatic way of doing it.

regards,

Ravi

Note : Please mark the helpful answers

5 REPLIES 5

Former Member
0 Kudos

Venkat,

You will have to do that manually by adding a field to the table and updating the field with the data, there is no automatic way of doing it.

regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

hii

append it to field catalogue

loop at itab ..

and increment it by 1 .

<b>X_FIELDCAT-FIELDNAME = 'serial'.

X_FIELDCAT-SELTEXT_L = 'SERIAL NO'.

X_FIELDCAT-NO_ZERO = 'X'.

X_FIELDCAT-OUTPUTLEN = 10.

X_FIELDCAT-COL_POS = 1.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.</b>

check this program..hope this solves your query

REPORT Z_50656_ALVSERIAL NO STANDARD PAGE HEADING MESSAGE-ID ZMSG

.

TYPE-POOLS: SLIS.

TABLES: VBAK.

DATA: BEGIN OF I_VBAK,

V_SNO(6) TYPE C,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

ERZET LIKE VBAK-ERZET,

ERNAM LIKE VBAK-ERNAM,

WAERK LIKE VBAK-WAERK,

END OF I_VBAK.

DATA: I_VBAK_TAB LIKE TABLE OF I_VBAK WITH HEADER LINE,

V_COUNT(6) TYPE N.

----


  • ALV-GRID DATA DECLARATION.

----


DATA: I_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV, " FIELD CATALOG.

W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,

I_LAYOUT TYPE SLIS_LAYOUT_ALV, " LAYOUT DECLARATION.

V_VARIANT TYPE DISVARIANT,

V_REPID LIKE SY-REPID.

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

----


  • START-OF-SELECTION.

----


START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM INSERT_SERIAL_NUMBER.

PERFORM GENERATE_ALV_FIELDCATALOGUE.

PERFORM DISPLAY_ALV_REPORT .

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA.

SELECT VBELN ERDAT ERZET ERNAM WAERK FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE I_VBAK_TAB

WHERE VBELN IN S_VBELN.

IF SY-SUBRC <> 0.

MESSAGE E006.

ENDIF.

ENDFORM. " get_data

&----


*& Form insert_serial_number

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM INSERT_SERIAL_NUMBER.

V_COUNT = 1.

LOOP AT I_VBAK_TAB.

I_VBAK_TAB-V_SNO = V_COUNT.

MODIFY I_VBAK_TAB TRANSPORTING V_SNO.

V_COUNT = V_COUNT + 1.

ENDLOOP.

ENDFORM. " insert_serial_number

&----


*& Form generate_alv_fieldcatalogue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GENERATE_ALV_FIELDCATALOGUE.

MOVE SY-REPID TO V_REPID.

I_LAYOUT-ZEBRA = 'X'.

I_LAYOUT-NO_INPUT = 'X'.

I_LAYOUT-BOX_TABNAME = 'I_VBAK_TAB'.

V_VARIANT-REPORT = V_REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'I_VBAK'

I_INCLNAME = V_REPID

CHANGING

CT_FIELDCAT = I_FIELDCATALOG

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT I_FIELDCATALOG INTO W_FIELDCATALOG.

CASE W_FIELDCATALOG-FIELDNAME.

WHEN 'V_SNO'.

W_FIELDCATALOG-SELTEXT_L = 'Serial Number'.

W_FIELDCATALOG-OUTPUTLEN = 15 .

ENDCASE.

MODIFY I_FIELDCATALOG FROM W_FIELDCATALOG.

ENDLOOP.

ENDFORM. " generate_alv_fieldcatalogue

&----


*& Form display_alv_report

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_ALV_REPORT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

I_GRID_TITLE = 'Test Program'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = I_FIELDCATALOG[]

I_SAVE = 'A'

IS_VARIANT = V_VARIANT

TABLES

T_OUTTAB = I_VBAK_TAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " display_alv_report

<b>Reward points if helpful</b>

Regards

Naresh

aris_hidalgo
Contributor
0 Kudos

Hi,

You have to get manually by fetching it from the database and then putting it into your internal table. Then in the fieldcat in your alv, declare the serial number field as your first.

Regards!

P.S. Please award points for helpful replies.

rahulkavuri
Active Contributor
0 Kudos

X_FIELDCAT_VBAK-FIELDNAME = 'SNO'.

X_FIELDCAT_VBAK-TABNAME = 'IT_NO'.

APPEND X_FIELDCAT_VBAK TO IT_FIELDCAT_VBAK.

CLEAR X_FIELDCAT_VBAK.

Take the serial number into a separate field of internal table 2 and keep on incrementing it by looping for all entries of the the main internal table 1 where the data is loaded...( i.e the number of records)

The number of records can be got by having this example

DATA: DUR TYPE TABLE OF RKE_DAT WITH HEADER LINE.

DATA: WORK_DAYS TYPE I.

DESCRIBE TABLE DUR LINES WORK_DAYS.

Loop the internal table 2 that number of times.. in the above xample WORK_DAYS gives the number of records

<b>By the way both the internal tables will have the same fieldcatalog</b>

Please award points if found helpful... this will solve ur prob definitely I think

Message was edited by: Rahul Kavuri

former_member188685
Active Contributor
0 Kudos

Hi venkat,

1. add additional field to store the serial number

2. after population of data in itab, loop at itab and increment the counter and populate the field.

3. populate the fieldcat for the field with position 1.

then you will be able to see in output,

but there is no straight forward way.

Regards

vijay