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: 

spool file data to internal table

Former Member
0 Kudos

Hi ,

I have spool file , I want to transfer spool file data to internal table , how can I acheive the same

thanks

bobby

4 REPLIES 4

Former Member
0 Kudos

Check this code out. Hope this helps. This code is to read spool data and print it.

SELECT SINGLE * FROM tsp01

WHERE rqident = p_spool.

MOVE-CORRESPONDING tsp01 TO wf_req_view.

  • Get Attrinbutes for the spool

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

authority = 'SP01'

client = wf_req_view-rqo1clie

name = wf_req_view-rqo1name

part = wf_req_view-rqo1part

IMPORTING

charco = wf_req_view-rqcharco

noof_parts = wf_req_view-rqparts

rectyp = wf_req_view-rqrectyp

size = wf_req_view-rqsize

stotyp = wf_req_view-rqstotyp

  • TYPE =

objtype = wf_req_view-rqdtype

locat = wf_req_view-rqlocat

EXCEPTIONS

fb_error = 2

fb_rsts_other = 3

no_object = 4

no_permission = 5

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

STOP.

ENDIF.

MOVE-CORRESPONDING wf_req_view TO wf_rq.

  • Read Spool Data in RAW format.

CALL FUNCTION 'RSPO_IRETURN_RAW_DATA'

EXPORTING

rq = wf_rq

TABLES

line_buffer = int_line_buffer

page_index = int_page_index

EXCEPTIONS

error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

STOP.

ENDIF.

wf_page_count = 9999.

  • Display Report.

PERFORM show_job TABLES int_line_buffer USING space

wf_page_count.

----


  • FORM SHOW_JOB *

----


  • ........ *

----


  • --> BUFFER *

  • --> IS_OTF *

  • --> wf_page_count *

----


FORM show_job TABLES buffer TYPE sp01r_data_set_t

USING is_otf page_count.

DATA: line_length TYPE rststype-linelength,

lowl(1024) TYPE c,

highl(1024) TYPE c,

offset TYPE i,

len TYPE i,

loc_spool(15).

loc_spool = p_spool.

  • SET PF-STATUS 'DISPLAY'.

CONCATENATE sy-title '-' 'Spool' loc_spool INTO sy-title.

NEW-PAGE LINE-SIZE p_linsiz.

CALL FUNCTION 'RSPO_SPOOLDATA_WRITE_INIT'.

LOOP AT buffer.

IF buffer-precol = 'P' AND buffer-data_line(1) = ' '.

NEW-PAGE.

CONTINUE.

ENDIF.

  • compute line length

IF buffer-data_len IS INITIAL.

line_length = strlen( buffer-data_line ) - 1.

ELSE.

line_length = buffer-data_len - 1.

ENDIF.

IF line_length > 0.

CALL FUNCTION 'RSPO_SPOOLDATA_WRITE'

EXPORTING

spool_data = buffer-data_line

data_length = line_length

EXCEPTIONS

data_too_short = 1

OTHERS = 2.

ELSE.

SKIP. " empty line

ENDIF.

ENDLOOP.

ENDFORM.

0 Kudos

Thanks Suresh,

This helped me to get a solution to a problem.

One of my custom program used the c-calls to transfer data from spool buffer into internal table. And then print the data thru a script.

CALL 'RSPOARSD'

ID 'BUFF' FIELD DATA_SET_LINE+5

ID 'DATALEN' FIELD DATA_SET_LENGTH

ID 'RC' FIELD RC

ID 'ERRMSG' FIELD ERRMSG.

I replaced this with the Function Module RSPO_IRETURN_RAW_DATA to read data from buffer into internal table.

Cheers Swati.

Former Member
0 Kudos

got the solution

0 Kudos

Hi Bobby,

Were you able to read the spool data. If yes, can I request you to please share the solution with us. Actually I have also come across the same kind of issue, I am able to read the spool but since the data in spool is too large it is getting truncated in the internal table.

Can you please suggest something on this. I have opened a thread also, you can refer the same.

Thanks,

Ashish