Sunday, April 3, 2016

How to read data from schedule job

DATAJOBNAME TYPE TBTCO-JOBNAME.
DATAJOBCOUNT TYPE TBTCO-JOBCOUNT.
DATALISTIDENT TYPE TBTCPV-LISTIDENT.
DATAJOBNO TYPE TSP01-RQIDENT.
DATADATE TYPE C LENGTH 12.

DATAflag TYPE I.

DATABEGIN OF i_outtab OCCURS 0,
  str
(255TYPE C,
END OF i_outtab.


DATABEGIN OF BUFFER OCCURS 100000,
  
TEXT(6000TYPE C,
END OF BUFFER.

DATAstartline TYPE Iendline 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(2SY-DATUM+4(2SY-DATUM+0(4INTO 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.

8 comments:

  1. Thank you it is really such a wonderful blogpost on sap videos Please Share More Information.

    ReplyDelete
  2. Thankyou for wonderful article. It has more Information in Your Website sap training videos.

    ReplyDelete
  3. I am planning to join sap abap with them after reading your blog.
    Hope the best will turn out.
    Call them at 8122241286 in chennai.
    www.thecreatingexperts.com

    ReplyDelete
  4. We provide sap abap technical course, call us to know more about us and join with us.
    Call them at 8122241286 in chennai.
    www.thecreatingexperts.com

    ReplyDelete
  5. SAP ABAP training is provided in CHENNAI.

    THE CREATING EXPERTS is one of the leading trainer in SAP who provides real time training

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    contact 8122241286

    ReplyDelete
  6. It was so nice article.I was really satisified by seeing this article sap training videos.

    ReplyDelete