Application Development and Automation 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: 
Read only

ALV grid

Former Member
0 Likes
876

Hi All,

I've written a report for displaying alv grid which can also be run in background.

but the output is in zig zag manner when run in background.

Please answer

Hi All,

I've written a report for displaying alv grid which can also be run in background.

but the output is in zig zag manner when run in background.

Please answer

5 REPLIES 5
Read only

Former Member
0 Likes
782

Hi Kiran,

Not very much clear the term 'Output is in zigzag manner'. Try Sorting the table before displaying.

Hope this will help!

Thanks,

Amol

Read only

Former Member
0 Likes
782

please check in the fieldcatalog , there only it is causing you some issue

Read only

Former Member
0 Likes
782

Hi,

try to increase the LINE-SIZE in report statement.

REPORT  zhdxrh63 NO STANDARD PAGE HEADING
                 LINE-SIZE 1050
                 MESSAGE-ID pn

.

Edited by: avinash kodarapu on Jan 2, 2009 12:57 PM

Read only

Former Member
0 Likes
782

Hi,

try below code

wf_fieldcat-col_pos = '1'.

wf_fieldcat-fieldname = '.

wf_fieldcat-seltext_l = text-009.

wf_fieldcat-tabname = 'I_FINAL1'."here pass internal table not the database table

Read only

former_member191735
Active Contributor
0 Likes
782

Output in Background displays in ZIG ZAG manner (as you said) if the internal table length is more than 256 characters. I think there are reports in SDN forums to get it nice.

All you have to pass the spool number and from line and to line. If you cannot find one. try the following

Well, the following code is from SDN forum but i dont know where is this post now. Thanks to the person who posted this code.

report zrca_readspool line-size 80.

  • global data from LSPOXTOP

tables: tsp01, tst05, tspoptions,tsp02l.

data: rc(10) type c,

errmsg(100) type c,

status like sy-subrc,

dsn_type(8) type c.

data: begin of data_set_line,

data_length(5),

precol(1),

data_line(5000),

end of data_set_line,

data_set_length(5) type c.

data: temse_name like tst01-dname,

temse_client like tst01-dclient,

temse_handle like rststype-handle,

temse_part like tst01-dpart,

temse_objtyp like tst01-dtype,

temse_rectyp like rststype-rectyp,

temse_charco like tst01-dcharcod.

data: is_otf.

  • global data from LSPOCTOP

data: begin of spoc,

first_bytes(4), " collection of the first bytes of the

" escape sequences.

prtctrl_start_length type i,

prtctrl_total_length type i,

prtctrl_start(10),

symbol_low_start(10),

symbol_hgh_start(10),

symbol_start_length type i,

icon_start(10),

icon_start_length type i,

icon_sel type i value 1,

frame_start(10),

frame_start_length type i,

end of spoc.

field-symbols: <spoc_prtctrl> type c ,

<spoc_frame> type c ,

<spoc_icon> type c ,

<spoc_symbol_low> type c ,

<spoc_symbol_hgh> type c .

  • copied from RSPO_DISPLAY_ABAP_SPOOLJOB

data: buffer like data_set_line occurs 1000.

selection-screen begin of block blk1 with frame title text-t01.

parameters: p_rqid like tsp01-rqident obligatory,

p_firstl type i default 0,

p_lastl type i default 2000 obligatory.

selection-screen end of block blk1.

******************************************************************

start-of-selection.

******************************************************************

start-of-selection.

select single * from tsp01 where rqident = p_rqid.

if sy-subrc <> 0.

write: / 'Spool request does not exist:'(001), p_rqid.

exit.

endif.

call function 'RSPO_CHECK_JOB_PERMISSION'

exporting

access = 'DISP'

spoolreq = tsp01

exceptions

no_permission = 1

others = 2.

if sy-subrc <> 0.

write: / 'No authorization to display'(002).

exit.

endif.

perform read_data tables buffer using tsp01 p_firstl p_lastl.

if sy-subrc <> 0.

write: / 'Error reading spoolo request'(003).

exit.

endif.

if is_otf = 'X'.

write: / 'This spool request is not an ABAP list'(004).

exit.

endif.

perform display_data tables buffer using tsp01-rqpaper tsp01-rqident.

******************************************************************************

  • Form Routimes

******************************************************************************

******************************************************************************

  • Form GET_SPOOL_LINE

******************************************************************************

form get_spool_line.

do.

if temse_rectyp+1(1) = 'Y'.

call 'C_RSTS_READ'

id 'HANDLE' field temse_handle

id 'BUFF' field data_set_line

  • ID 'BUFFLG' FIELD 1006

id 'BUFFLG' field 5006 "MODAB

id 'ALLINE' field 'X'

id 'BINARY' field ' '

id 'SHOWLG' field 'X'

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

else.

call 'C_RSTS_READ'

id 'HANDLE' field temse_handle

id 'BUFF' field data_set_line+1

*

id 'BUFFLG' field 1005

id 'BUFFLG' field 5005 "MODAB

id 'ALLINE' field 'X'

id 'BINARY' field ' '

id 'SHOWLG' field 'X'

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

data_set_line(5) = data_set_line+1(5).

data_set_line-precol = ' '.

add 1 to data_set_line-data_length.

endif.

status = sy-subrc.

if status <> 6. " EOF, error condition, or got data

exit.

endif.

  • end of this part, try to open next part

add 1 to temse_part.

call 'C_RSTS_CLOSE'

id 'HANDLE' field temse_handle

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

if status = 0.

call function 'RSTS_GET_ATTRIBUTES'

exporting

authority = 'SP01'

client = temse_client "hjl

name = temse_name

part = temse_part

importing

charco = temse_charco

rectyp = temse_rectyp

objtype = temse_objtyp

exceptions

fb_error = 1

fb_rsts_other = 2

no_object = 3

no_permission = 4

others = 5.

status = sy-subrc.

endif.

if status = 0.

call 'C_RSTS_OPEN_READ'

id 'HANDLE' field temse_handle

id 'CLIENT' field temse_client "hjl

id 'NAME' field temse_name

id 'PART' field temse_part

id 'TYPE' field temse_objtyp

id 'CONV' field ' '

id 'ALLINE' field 'X'

id 'BINARY' field ' '

id 'RECTYP' field temse_rectyp

id 'CHARCO' field temse_charco

id 'PROM' field 'I'

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

endif.

enddo.

if status = 4.

status = 12. "EOF

endif.

if status = 8.

status = 40. "Line too long

endif.

data_set_length = data_set_line-data_length.

endform. "GET_SPOOL_LINE

&----


*& Form READ_DATA

&----


form read_data tables buffer

using tsp01 like tsp01

value(first) type i

value(last) type i.

data: lines type i.

refresh buffer.

clear is_otf.

temse_client = tsp01-rqclient.

temse_name = tsp01-rqo1name.

temse_part = 1.

call function 'RSTS_GET_ATTRIBUTES'

exporting

authority = 'SP01'

client = temse_client

name = temse_name

part = temse_part

importing

charco = temse_charco

rectyp = temse_rectyp

objtype = temse_objtyp

exceptions

fb_error = 1

fb_rsts_other = 2

no_object = 3

no_permission = 4

others = 5.

if sy-subrc = 0.

if temse_objtyp(3) = 'OTF'.

is_otf = 'X'.

endif.

else.

exit.

endif.

clear temse_handle.

call 'C_RSTS_OPEN_READ'

id 'HANDLE' field temse_handle

id 'CLIENT' field temse_client "hjl

id 'NAME' field temse_name

id 'PART' field temse_part

id 'TYPE' field temse_objtyp

id 'CONV' field ' '

id 'ALLINE' field 'X'

id 'BINARY' field ' '

id 'RECTYP' field temse_rectyp

id 'CHARCO' field temse_charco

id 'PROM' field 'I'

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

if status = 0.

do.

perform get_spool_line.

if status <> 0 and status <> 40 and status <> 12.

perform close_job.

exit.

endif.

if status <> 12. " 12 = End

if not ( data_set_length is initial ).

data_set_line-data_length = data_set_length - 1.

endif.

add 1 to lines.

if lines >= first.

append data_set_line to buffer.

endif.

if ( not last is initial ) and ( lines >= last ).

exit.

endif.

else.

if lines = 0.

perform close_job.

exit.

endif.

if lines < first .

perform close_job.

exit.

endif.

exit.

endif.

enddo.

perform close_job.

endif.

endform. "READ_DATA

----


  • FORM CLOSE_JOB *

----


form close_job.

if status <> 0 and status <> 12.

call 'C_RSTS_CLOSE'

id 'HANDLE' field temse_handle

id 'RC' field rc

id 'ERRMSG' field errmsg.

message e112(po) with status rc errmsg raising read_error.

endif.

call 'C_RSTS_CLOSE'

id 'HANDLE' field temse_handle

id 'RC' field rc

id 'ERRMSG' field errmsg.

status = sy-subrc.

if status <> 0.

message e112(po) with status rc errmsg raising read_error.

endif.

endform. "CLOSE_JOB

&----


*& Form DISPLAY_DATA

&----


form display_data tables buffer using rqpaper like tsp01-rqpaper

rqid like tsp01-rqident.

data: line_length type i,

gcol type i,

glines type i,

line_length2 like rststype-linelength,

v,

v2.

call function 'RSPO_SPOOLDATA_WRITE_INIT'.

perform spooldata_write_init. "MODAB

select single * from tspoptions where spoption = 'REALWIDTH'.

if sy-subrc = 0.

v = 'X'.

endif.

select single *

from tspoptions where spoption = 'REALHEIGHT'.

if sy-subrc = 0.

v2 = 'X'.

endif.

if not v is initial or not v2 is initial.

gcol = 0.

glines = 0.

select single * from tsp02l where pjident = rqid and pjnummer = 0.

if sy-subrc = 0.

gcol = tsp02l-columns.

glines = tsp02l-lines.

else.

call function 'RSPO_GET_SIZE_OF_LAYOUT'

exporting

layout = rqpaper

importing

columns = gcol

lines = glines.

endif.

endif.

if gcol < 80 or v is initial.

gcol = 1023.

endif.

if glines < 5 or v2 is initial.

glines = 0.

endif.

if gcol >= 1024. "MODAB

gcol = 1023.

endif.

new-page no-heading no-title line-size gcol line-count glines. " make a wide list

set blank lines on.

loop at buffer.

data_set_line = buffer.

if data_set_line-precol = 'P'.

if data_set_line(1) = ' '. " Echter Vorschub ?"

new-page.

endif.

continue.

endif.

  • Zeilenlange berechnen, falls unbekannt.

if data_set_line-data_length is initial.

line_length = strlen( data_set_line-data_line ).

else.

line_length = data_set_line-data_length.

endif.

if line_length > 0.

line_length2 = line_length.

perform spooldata_write using data_set_line-data_line "MODAB

line_length2 1.

else. " Leerzeile

skip.

endif.

endloop.

endform. "DISPLAY_DATA

&----


*& Form SPOOLDATA_WRITE

&----


  • copied from RSPO_SPOOLDATA_WRITE

form spooldata_write

using value(spool_data)

value(data_length) like rststype-linelength

value(start_pos) like sy-colno.

  • function globals

data: lpos like sy-colno,

rest_len type i,

area_len type i,

next_hot type i, " offset of next special character

cols type i, " columns used by special character

bytes type i, " bytes used by special character

hot2,

hot3,

hot4,

hot5,

hot6,

hot7,

begin of escape_trick,

x1(1) type x,

end of escape_trick,

the_prtctrl(5) type c,

  • Because of a problem within the ABAP listprocessing, I shall

  • never output the same icon side by side with the same color

  • and without a gap.

  • As I don't know the data, I will use two different variables

  • alternatively.

icon_id1 like icons-l4,

icon_id2 like icons-l4.

field-symbols: <ldata> ,

<plain_text> ,

<prtctrl> ,

<hot_prtctrl> ,

<hot_frame> ,

<hot_icon> ,

<hot_symbol> ,

<p>.

if start_pos < 2.

write at / ' ' no-gap.

new-line.

lpos = 1.

else.

lpos = start_pos.

endif.

rest_len = strlen( spool_data ).

describe field spool_data length area_len in byte mode.

if data_length = 0. " fine.

elseif data_length <= area_len.

rest_len = data_length.

else.

write: / 'Fehler beim Decodieren der Listendaten'(005).

stop.

endif.

check rest_len > 0.

assign spool_data(rest_len) to <ldata>.

while <ldata> ca spoc-first_bytes.

next_hot = sy-fdpos.

if next_hot > 0.

assign <ldata>(next_hot) to <plain_text>.

perform write_bigfield using <plain_text> next_hot lpos.

write at lpos <plain_text> no-gap.

add next_hot to lpos.

subtract next_hot from rest_len.

assign <ldata>+next_hot(rest_len) to <ldata>.

endif.

if rest_len >= spoc-prtctrl_start_length.

assign <ldata>(spoc-prtctrl_start_length) to <hot_prtctrl>.

else.

assign 'too_short' to <hot_prtctrl>.

endif.

if rest_len >= spoc-frame_start_length.

assign <ldata>(spoc-frame_start_length) to <hot_frame>.

else.

assign 'too_short' to <hot_frame>.

endif.

if rest_len >= spoc-icon_start_length.

assign <ldata>(spoc-icon_start_length) to <hot_icon>.

else.

assign 'too_short' to <hot_icon>.

endif.

if rest_len >= spoc-symbol_start_length.

assign <ldata>(spoc-symbol_start_length) to <hot_symbol>.

else.

assign 'too_short' to <hot_symbol>.

endif.

if rest_len > 1.

hot2 = <ldata>+1(1).

if rest_len > 2.

hot3 = <ldata>+2(1).

if rest_len > 3.

hot4 = <ldata>+3(1).

else.

hot4 = '?'.

endif.

else.

hot3 = '?'.

endif.

else.

hot2 = '?'.

endif.

if <hot_frame> = <spoc_frame>.

cols = 1. " in most cases.

bytes = 2. " in most cases.

case hot2.

when '0'.

write at lpos hot2 as line no-gap.

when '1'.

write at lpos hot2 as line no-gap.

when '2'.

write at lpos hot2 as line no-gap.

when '3'.

write at lpos hot2 as line no-gap.

when '4'.

write at lpos hot2 as line no-gap.

when '5'.

write at lpos hot2 as line no-gap.

when '6'.

write at lpos hot2 as line no-gap.

when '7'.

write at lpos hot2 as line no-gap.

when '8'.

write at lpos hot2 as line no-gap.

when '9'.

write at lpos hot2 as line no-gap.

when ':'.

write at lpos hot2 as line no-gap.

when ';'. " box_drawings_light_left

write at lpos '4' as line no-gap.

when '<'. " box_drawings_light_up

write at lpos '5' as line no-gap.

when '='. " box_drawings_light_right

write at lpos '4' as line no-gap.

when '>'. " box_drawings_light_down

write at lpos '5' as line no-gap.

when '?'. " drawings_checkbox_off

write at lpos ' ' as checkbox input off no-gap.

when '@'. " drawings_checkbox_on

write at lpos 'X' as checkbox input off no-gap.

when others.

bytes = 0.

endcase.

endif.

if <hot_symbol> = <spoc_symbol_low>.

escape_trick-x1 = hot3.

subtract 32 from escape_trick-x1.

if hot4 = space.

write at lpos(2) escape_trick as symbol no-gap.

cols = 2.

bytes = 4.

else.

write at lpos(1) escape_trick as symbol no-gap.

bytes = 3.

endif.

endif.

if <hot_symbol> = <spoc_symbol_hgh>.

escape_trick-x1 = hot3.

add 32 to escape_trick-x1.

if hot4 = space.

write at lpos(2) escape_trick as symbol no-gap.

cols = 2.

bytes = 4.

else.

write at lpos(1) escape_trick as symbol no-gap.

bytes = 3.

endif.

endif.

if <hot_icon> = <spoc_icon>.

if spoc-icon_sel >< 1.

spoc-icon_sel = 1.

icon_id1 = '@00@'.

icon_id1+1(1) = hot3.

icon_id1+2(1) = hot4.

else.

spoc-icon_sel = 2.

icon_id2 = '@00@'.

icon_id2+1(1) = hot3.

icon_id2+2(1) = hot4.

endif.

if rest_len > 4.

hot5 = <ldata>+4(1).

if rest_len > 5.

hot6 = <ldata>+5(1).

if rest_len > 6.

hot7 = <ldata>+6(1).

else.

hot7 = '?'.

endif.

else.

hot6 = '?'.

endif.

else.

hot5 = '?'.

endif.

if hot5 = space.

if hot6 = space.

if hot7 = space.

if spoc-icon_sel = 1.

write at lpos(4) icon_id1 as icon.

write at lpos icon_id1 as icon no-gap.

else.

write at lpos(4) icon_id2 as icon.

write at lpos icon_id2 as icon no-gap.

endif.

cols = 4.

bytes = 7.

else.

if spoc-icon_sel = 1.

write at lpos(3) icon_id1 as icon.

write at lpos icon_id1 as icon no-gap.

else.

write at lpos(3) icon_id2 as icon.

write at lpos icon_id2 as icon no-gap.

endif.

cols = 3.

bytes = 6.

endif.

else.

if spoc-icon_sel = 1.

write at lpos(2) icon_id1 as icon.

write at lpos icon_id1 as icon no-gap.

else.

write at lpos(2) icon_id2 as icon.

write at lpos icon_id2 as icon no-gap.

endif.

cols = 2.

bytes = 5.

endif.

else. "rite at lpos(1) icon_id as icon.

write at lpos(1) '#' no-gap. " Not enough space for any icon.'#'

cols = 1.

bytes = 4.

endif.

endif.

if <hot_prtctrl> = <spoc_prtctrl>.

cols = 0. " in most cases.

bytes = 6. " in most cases.

if rest_len >= spoc-prtctrl_total_length.

the_prtctrl = <ldata>+spoc-prtctrl_start_length(5).

if the_prtctrl = 'SABLD'.

format intensified on. "no 3.0 'SAULN'. "no 3.0 FORMAT UNDERSCORED ON.

elseif the_prtctrl = 'SAOFF'.

format intensified off. "no 3.0 FORMAT UNDERSCORED OFF.

elseif the_prtctrl(3) = 'COL'.

case the_prtctrl+3(1).

when '0'.

format color off.

when '1'.

format color 1.

when '2'.

format color 2.

when '3'.

format color 3.

when '4'.

format color 4.

when '5'.

format color 5.

when '6'.

format color 6.

when '7'.

format color 7.

endcase.

case the_prtctrl+4(1).

when 'N'.

format intensified off inverse off.

when 'H'.

format intensified on inverse off.

when 'V'.

format intensified on inverse on.

endcase.

endif. "printcontrol

else. "??

endif.

endif.

if bytes = 0.

bytes = 1.

write at lpos(1) '#'. "#.

cols = 1.

endif.

add cols to lpos.

subtract bytes from rest_len.

if rest_len > 0.

assign <ldata>+bytes(rest_len) to <ldata>.

else.

exit.

endif.

endwhile.

if rest_len > 0.

assign <ldata>(rest_len) to <plain_text>.

perform write_bigfield using <plain_text> rest_len lpos.

endif.

endform. "SPOOLDATA_WRITE

&----


*& Form WRITE_BIGFIELD

&----


form write_bigfield using value(field) type c value(len) value(pos).

data: l_chunk type i.

while len > 0.

if len > 255.

l_chunk = 255.

else.

l_chunk = len.

endif.

write at pos field(l_chunk) no-gap.

add l_chunk to pos.

len = len - l_chunk.

if len > 0.

field = field+l_chunk.

endif.

endwhile.

endform. "WRITE_BIGFIELD

&----


*& Form SPOOLDATA_WRITE_INIT

&----


  • text

----


form spooldata_write_init.

  • Copy from RSPO_SPOOLDATA_WRITE_INIT

data: begin of escape_trick ,

x1(1) type x ,

end of escape_trick .

field-symbols: <ldata> ,

<plain_text> ,

<prtctrl> .

perform set_char using '1C' changing spoc-prtctrl_start.

spoc-prtctrl_start_length = 1.

spoc-prtctrl_total_length = spoc-prtctrl_start_length + 5.

assign spoc-prtctrl_start(spoc-prtctrl_start_length) to <spoc_prtctrl>.

perform set_char using '1B' changing spoc-frame_start.

spoc-frame_start_length = 1.

assign spoc-frame_start(spoc-frame_start_length) to <spoc_frame>.

perform set_char using '1B' changing spoc-icon_start.

spoc-icon_start+1 = ','.

spoc-icon_start_length = 2.

assign spoc-icon_start(spoc-icon_start_length) to <spoc_icon>.

perform set_char using '1B' changing spoc-symbol_low_start.

spoc-symbol_low_start+1 = '('.

perform set_char using '1B' changing spoc-symbol_hgh_start.

spoc-symbol_hgh_start+1 = ')'.

spoc-symbol_start_length = 2.

assign spoc-symbol_low_start(spoc-symbol_start_length) to <spoc_symbol_low>.

assign spoc-symbol_hgh_start(spoc-symbol_start_length) to <spoc_symbol_hgh>.

spoc-first_bytes+0(1) = spoc-prtctrl_start(1).

spoc-first_bytes+1(1) = spoc-frame_start(1).

spoc-first_bytes+2(1) = spoc-icon_start(1).

spoc-first_bytes+3(1) = spoc-symbol_low_start(1).

endform. "SPOOLDATA_WRITE_INIT

&----


*& Form set_char

&----


form set_char using code changing c.

  • Copy from RSPO_SPOOLDATA_WRITE_INIT

data: l_buf(1) type c.

data: l_len type i.

field-symbols: <fs> type x.

assign l_buf to <fs> type 'X'.

l_buf = 'A'.

describe field l_buf length l_len in byte mode.

if l_len = 2.

if <fs>(1) = 0.

<fs>+0(1) = 0.

<fs>+1(1) = code.

else.

<fs>+1(1) = 0.

<fs>+0(1) = code.

endif.

else.

<fs>+0(1) = code.

endif.

c = l_buf.

endform. "set_char