SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Show SM35 Messages



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Mon Feb 16, 2009 1:22 pm    Post subject: Show SM35 Messages Reply with quote

Source from: http://www.sapfans.com/forums/viewtopic.php?t=15383
Author: Richard Harper

Code:
Types: Begin of joblogs,                            " Job log w/a
             DDate(10) type c,                      " Display date
             DTime(8)  type c,                      " Display time
             Mart      like bdclm-mart,             " Message type
             mid       like bdclm-mid,              " Message ID
             mnr       like bdclm-mnr,              " Number
             Text(90)  type c,                      " Message text
       End of joblogs.
       End of joblogs,
*
*      Tree structure for reporting results from N006 and N015.
*
       Begin of program_results,
             Progm    like trdir-name,             " Program name
             Versn    type Zversion,               " Version No - 006
             CostCtr  type C,                      " Cost centre flag
             Batch    like apqi-groupid,           " Batch flag
             File     type string,                 " Output file for GUI
             PFile    like rlgrap-filename,        " Output file Print
             Result   type boolean,                " OK or not ok
             Msg(255) type c,                      " Error message
             List     type ABAPLIST Occurs 0,      " Listing Results
             jobname  like tbtcjob-jobname,        " Job name for batch
             TemSeId  like apql-TemSeId,           " TemseId for job log
             JobLog   type joblogs Occurs 0,
       End of Program_Results.

Data: g_Results type Program_Results occurs 0.

Start-of-Selection
...
...
...
*
*          Get the batch logs,
*
           Perform Get_log tables g_results-joblog
                            using g_results-TemSeId.
*
*          Find any 'E' or 'A' class messages.
*
           Loop at g_results-joblog into g_joblog.
                If g_joblog-Mart = c_error
                   or g_joblog-Mart = c_abort.
                      If g_results-msg <> ''.
                         Append g_results to t_results.
...
...
...
EndForm.

*Eject
***********************************************************************
*
*       Procedure:     Get_Log
*
*       Purpose:       Gets the log for a selected job.
*
*                      NOTE: BP_JOBLOG_READ returns the wrong log -
*                            that just shows job start, running and end.
*
*       Entry:         TemSeId of job log.
*
*       Exit:          Table of expanded text messages
*
*       Called By:
*
*       Calls:
*
*       Modification History:
*
*   Date    Reason                                         Version  Who
*
Form Get_Log Tables t_joblog
             using pu_TemSeId like Apql-TemSeId.
*
     Data: Begin Of t_logtable Occurs 50,  " Plain Log Info In Temse
                 Enterdate Like Btctle-Enterdate,
                 Entertime Like Btctle-Entertime,
                 Logmessage(400) Type C,
           End Of t_logtable,
*
           Begin Of t_bdclm  Occurs 0.        " Log message Structure
                 Include Structure bdclm.
     Data:       Counter Type I,
                 Longtext Type Bdc_Mpar,
           End Of t_bdclm,
*
           w_joblog        type JobLogs,
           w_External_Date(10),               " Display date
           w_Internal_Date Type D,
           W_Msgv1         Like T100-Text,    " Message variables 1,2,3
           W_Msgv2         Like T100-Text,
           W_Msgv3         Like T100-Text,
           W_Msgv4         Like T100-Text,    " and 4
           W_Mlen          Type I,            " Current message v length
           W_Subscr(1)     Type N,            " Current message variable
           W_Varname(7)    Type C.            " Message variable name
*
     Field-Symbols: <F_Field>.                " Pointer to current msgv
*
*    Open the log,  read it and then close it.
*
     Call Function 'RSTS_OPEN_RLC'
       Exporting
         Name         = pu_temSeId
         Client       = sy-mandt
         Authority    = 'Batch'
         Prom         = 'I'
         Rectyp       = 'VNL----'
       Exceptions
         Fb_Call_Handle =  4
         Fb_Error       =  8
         Fb_Rsts_Noconv = 12
         Fb_Rsts_Other  = 16
         No_Object      = 20
         Others         = 24.
     If sy-subrc = 0.
        Call Function 'RSTS_READ'
          Tables
            Datatab  = t_logtable
          Exceptions
            Fb_Call_Handle =  4
            Fb_Error       =  8
            Fb_Rsts_Noconv = 12
            Fb_Rsts_Other  = 16
            Others         = 16.
        If sy-subrc = 0.
           Call Function 'RSTS_CLOSE'
             Exceptions
               Others = 0.
*
*          The log messages are held as t100 messages with the message
*          variables in a single string.
*
           Clear t_bdclm[].
           Loop At t_logtable.
*
*               Get a displayable version of the date.  If there's
*               a problem,  don't display this record.
*
                Call 'DATE_CONV_INT_TO_EXT'
                  Id 'DATINT' Field t_logtable-Enterdate
                  Id 'DATEXT' Field w_External_Date.
                Call 'DATE_CONV_EXT_TO_INT'
                  Id 'DATEXT' Field w_External_Date
                  Id 'DATINT' Field w_Internal_Date.
                If Sy-Subrc Ne 0.
                   Continue.
                Endif.
                Clear t_bdclm.
                t_bdclm-Indate  = t_logtable-Enterdate.
                t_bdclm-Intime  = t_logtable-Entertime.
                t_bdclm+14      = t_logtable-Logmessage.
                Append t_bdclm.
           Endloop.
*
*          Decode the messages in t_bdclm inserting the variable parts
*          of the message.
*
           Loop At t_bdclm.
                Clear: W_Msgv1,
                       W_Msgv2,
                       W_Msgv3,
                       W_Msgv4.
*
*               Any variable parts in this message ?
*
                If t_bdclm-Mparcnt > 0.              "#EC PORTABLE
*
*                  Message variables in MPar are held in a single
*                  string.  Two bytes precede each variable with the
*                  variable length.
*
                   Do.
*
*                      Get the current variable length and remove that
*                      from the start of the string.
*
                       Move t_bdclm-Mpar+0(2) To W_Mlen.
                       Move t_bdclm-Mpar+2    To t_bdclm-Mpar.
*
*                      Calculate the message variable this is for
*
                       Move Sy-Index          To W_Subscr.
                       Concatenate 'W_Msgv' W_Subscr Into W_Varname.
                       Assign (W_Varname) To <F_Field>.
*
*                      Move the variable to the correct message var and
*                      check if there are any more variable parts to
*                      process.
*
                       Move t_bdclm-Mpar+0(W_Mlen) To <F_Field>.
                       Move t_bdclm-Mpar+W_Mlen To t_bdclm-Mpar.
                       If Sy-Index >= t_bdclm-Mparcnt.     "#EC PORTABLE
                          Exit.
                       Endif.
                   Enddo.
                Endif.
*
*               Finally build the complete message and place it in the
*               output table.
*
                Clear w_joblog.
                Move-corresponding t_bdclm to w_joblog.
                Move w_external_date to w_joblog-ddate.
                Call Function 'MESSAGE_TEXT_BUILD'
                  Exporting
                    Msgid                     = t_bdclm-Mid
                    Msgnr                     = t_bdclm-Mnr
                    Msgv1                     = W_Msgv1
                    Msgv2                     = W_Msgv2
                    Msgv3                     = W_Msgv3
                    Msgv4                     = W_Msgv4
                 Importing
                    Message_Text_Output       = W_joblog-text.
                Append w_joblog to t_joblog.
           Endloop.
        EndIf.
     EndIf.
EndForm.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.