SAP Tutorials Blog

 

 


DATA: JOBNAME TYPE TBTCO-JOBNAME.

DATA: JOBCOUNT TYPE TBTCO-JOBCOUNT.

DATA: LISTIDENT TYPE TBTCPV-LISTIDENT.

DATA: JOBNO TYPE TSP01-RQIDENT.

DATA: DATE TYPE C LENGTH 12.


DATA: flag TYPE I.


DATA: BEGIN OF i_outtab OCCURS 0,

  str(255) TYPE C,

END OF i_outtab.



DATA: BEGIN OF BUFFER OCCURS 100000,

  TEXT(6000) TYPE C,

END OF BUFFER.


DATA: startline TYPE I, endline TYPE I.



" GETTING DATE WISE SPOOL NUMBER


SELECT SINGLE JOBCOUNT FROM TBTCO INTO JOBCOUNT WHERE JOBNAME = 'job_name' AND SDLSTRTDT = SY-DATUM.


SELECT SINGLE LISTIDENT FROM TBTCPV INTO LISTIDENT WHERE JOBCOUNT = JOBCOUNT AND JOBNAME = 'job_name' .


CONCATENATE SY-DATUM+6(2) SY-DATUM+4(2) SY-DATUM+0(4) INTO DATE SEPARATED BY '_'.

JOBNO = LISTIDENT.


IF JOBNO NE '0'.

  " FETCHING SPOOL DATA TO BUFFER

  startline = 1.


  DO.

    REFRESH BUFFER.

    endline = startline + 99999.

    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'

    EXPORTING

      rqident              = JOBNO

      first_line           = startline

      last_line            = endline

      desired_type         = 'RAW'

  

    TABLES

      BUFFER               = BUFFER

    EXCEPTIONS

      no_such_job          = 1

      job_contains_no_data = 2

      selection_empty      = 3

      no_permission        = 4

      can_not_access       = 5

      read_error           = 6

      type_no_match        = 7

      OTHERS               = 8.

    IF sy-subrc <> 0.

      EXIT.

    ENDIF.


    LOOP AT BUFFER.

      i_outtab-str = BUFFER-TEXT.

      APPEND i_outtab.

      CLEAR i_outtab.

    ENDLOOP.

    startline = endline + 1.

  ENDDO.


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com