Skip to Content

Sometimes we’re asked to develop applications that keeps some information in the Spool. They’re useful of course, because you can print them whenever you want.

Now, supposed that your at home, taking a nap and your boss calls you telling that there’s some error in the output list…You could use your Tasting the mix of PHP and SAP – Volume 7 and tried to guess what went wrong…But, if you don’t have it then this is your best choise…Just choose the Spool request generated by you application and you can watch it, print it or even delete it -;)

First, we need to create some “Z” functions…Why? Because the standard functions to manage Spool requests are not RFC enabled…

ZRSPO_IRETURN_RAW_DATA

This function is used to read spool request info.

FUNCTION ZRSPO_IRETURN_RAW_DATA.

*”—-


“Local interface:

*”  IMPORTING

*”     VALUE(RQ) LIKE  TSP01SYS STRUCTURE  TSP01SYS

*”     VALUE(LIST_FIRST) LIKE  RSPOTYPE-PAGE DEFAULT 1

*”     VALUE(LIST_COUNT) LIKE  RSPOTYPE-PAGE DEFAULT 0

*”     VALUE(LIST_END) LIKE  RSPOTYPE-MODE DEFAULT ‘ ‘

*”     VALUE(OTF_FIRST) LIKE  RSPOTYPE-PAGE DEFAULT 1

*”     VALUE(OTF_COUNT) LIKE  RSPOTYPE-PAGE DEFAULT 0

*”     VALUE(OTF_END) LIKE  RSPOTYPE-MODE DEFAULT ‘ ‘

*”     VALUE(SHORT) TYPE  ABAPTYPE DEFAULT ‘X’

*”  EXPORTING

*”     VALUE(MORE_DATA) LIKE  RSPOTYPE-MODE

*”     VALUE(COL_HEADER) LIKE  RSPOTYPE-PRTCTL

*”     VALUE(OTF_HEADER) LIKE  ITCOO STRUCTURE  ITCOO

*”     VALUE(LAST_PAGE) LIKE  RSPOTYPE-PAGE

*”  TABLES

*”      LINE_BUFFER STRUCTURE  RSPO_DS OPTIONAL

*”      PAGE_INDEX STRUCTURE  RSPO_INDEX

*”      LINE_BUFFER2 STRUCTURE  RSPO_DS2 OPTIONAL

*”  EXCEPTIONS

*”      ERROR

*”—-


DEFINE TEXT_MESSAGE.

  IF SY-SUBRC

FUNCTION ZREAD_SPOOL.

*”—-


“Local interface:

*”  IMPORTING

*”     VALUE(RQIDENT) TYPE  TSP01-RQIDENT OPTIONAL

*”     VALUE(RQOWNER) TYPE  TSP01-RQOWNER OPTIONAL

*”     VALUE(RQCRETIME_INI) TYPE  TSP01-RQCRETIME OPTIONAL

*”     VALUE(RQCRETIME_END) TYPE  TSP01-RQCRETIME OPTIONAL

*”  TABLES

*”      SPOOL_TABLE STRUCTURE  TSP01

*”  EXCEPTIONS

*”      SPOOL_NOT_FOUND

*”—-


  DATA: BEGIN OF R_DATUM OCCURS 1,

        SIGN(1),

        OPTION(2),

        LOW  TYPE TSP01-RQCRETIME,

        HIGH TYPE TSP01-RQCRETIME,

        END OF R_DATUM.

  DATA: BEGIN OF R_SPOOL OCCURS 1,

        SIGN(1),

        OPTION(2),

        LOW  TYPE TSP01-RQIDENT,

        HIGH TYPE TSP01-RQIDENT,

        END OF R_SPOOL.

  DATA: BEGIN OF R_OWNER OCCURS 1,

        SIGN(1),

        OPTION(2),

        LOW  TYPE TSP01-RQOWNER,

        HIGH TYPE TSP01-RQOWNER,

        END OF R_OWNER.

  R_DATUM-SIGN = ‘I’.

  IF RQCRETIME_INI EQ SPACE AND RQCRETIME_END EQ SPACE.

    R_DATUM-OPTION = ‘ ‘.

  ELSEIF RQCRETIME_INI NE SPACE AND RQCRETIME_END NE SPACE.

    R_DATUM-OPTION = ‘BT’.

    CONCATENATE RQCRETIME_INI ‘00000000’

    INTO R_DATUM-LOW.

    CONCATENATE RQCRETIME_END ‘99999999’

    INTO R_DATUM-HIGH.

    APPEND R_DATUM.

  ELSE.

    R_DATUM-OPTION = ‘EQ’.

    CONCATENATE RQCRETIME_INI ‘00000000’

    INTO R_DATUM-LOW.

    APPEND R_DATUM.

  ENDIF.

  IF RQIDENT NE SPACE.

    R_SPOOL-OPTION = ‘EQ’.

    R_SPOOL-SIGN = ‘I’.

    R_SPOOL-LOW = RQIDENT.

  ENDIF.

  IF RQOWNER NE SPACE.

    R_OWNER-OPTION = ‘EQ’.

    R_OWNER-SIGN = ‘I’.

    R_OWNER-LOW = RQOWNER.

  ENDIF.

  SELECT *

  INTO TABLE SPOOL_TABLE

  FROM TSP01

  WHERE RQIDENT IN R_SPOOL

    AND RQOWNER IN R_OWNER

    AND RQCRETIME IN R_DATUM.

  IF SY-SUBRC NE 0.

    RAISE SPOOL_NOT_FOUND.

  ENDIF.

ENDFUNCTION.

ZRSPO_IDELETE_SPOOLREQ

This function is used to delete a spool request.

FUNCTION ZRSPO_IDELETE_SPOOLREQ.

*”—-


“Local interface:

*”  IMPORTING

*”     VALUE(SPOOLREQ) LIKE  TSP01SYS STRUCTURE  TSP01SYS

*”  EXPORTING

*”     VALUE(RC) LIKE  RSPOTYPE-RC

*”     VALUE(STATUS) LIKE  SY-SUBRC

*”  EXCEPTIONS

*”      ERROR

*”—-


DATA: L_SPOOLID LIKE TSP01_SP0R-RQID_CHAR,

      MSG_TEXT(80) TYPE C,

      TI VALUE ‘I’.

  L_SPOOLID = SPOOLREQ-RQIDENT.

  IF SPOOLREQ-SYS = SY-SYSID.

    CALL FUNCTION ‘RSPO_R_RDELETE_SPOOLREQ’

         EXPORTING

              SPOOLID = L_SPOOLID

         IMPORTING

              RC      = RC

              STATUS  = STATUS.

  ELSE.

    CALL FUNCTION ‘RSPO_R_RDELETE_SPOOLREQ’

      DESTINATION SPOOLREQ-SYS

         EXPORTING

              SPOOLID = L_SPOOLID

         IMPORTING

              RC      = RC

              STATUS  = STATUS

         EXCEPTIONS

              COMMUNICATION_FAILURE = 102 MESSAGE MSG_TEXT

              SYSTEM_FAILURE        = 103 MESSAGE MSG_TEXT

              OTHERS                = 1.

    IF SY-SUBRC

   body

   #login

 

if(isset($_POST[‘LOG_IN’]) || (isset($_POST[‘Table’])) || (isset($_GET[‘Back’])))
{
if(!isset($_SESSION[“Server”]))
{
$_SESSION[“Server”] = $_POST[“Server”];
$_SESSION[“Sysnum”] = $_POST[“Sysnum”];
$_SESSION[“Client”] = $_POST[“Client”];
$_SESSION[“User”] = $_POST[“User”];
$_SESSION[“Pass”] = $_POST[“Pass”];
}

$Login = new Login();
$Log_Me = $Login->Log_In($_SESSION[“Server”],$_SESSION[“Sysnum”],$_SESSION[“Client”],
$_SESSION[“User”],$_SESSION[“Pass”]);
$RFC_Me = $Login->RFC_Connection($Log_Me);

PRINT(“

“);
PRINT(“

“);
PRINT(“

“);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“”);
PRINT(“

Spool Number:

Spool Owner:

Creation Time:

“);
PRINT(“

“);
PRINT(“

“);
PRINT(“Log Out“);
PRINT(“

“);

}
else
{
$_SESSION = array();
session_destroy();

$Login = new Login();
$Login->Login_Page();
}

?>

Choose_Spool.php

An intermediate page for managing requests.

   body

   #login

 

image

Watch you Spool request.

image

You can print directly from you browser.

image

I hope you like this one. It’s simple but it can be useful.

Francisco Bilog told me that

ZREAD_SPOOL

was missing…So I fix the blog -:)

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply