Sunday 21 July 2013

Tutorial to View Processed background Job in SAP ABAP (SM37)

Below are the steps to be followed to view the logs for the processed Background Job:

GoTo SM37 Transaction Code, Provide the Job Name if you know it and put '*' for User Name OR Provide your User-Id in User Name field and put '*' for Job Name field OR you can provide Both!!

You can check or un-check the job status fields depending up on your requirement, provide the Job start condition values(from date and to date).
Click on Execute Button.






















In the Next Screen you can see the Job status and its details.














If you would like to see the output screen, then select the Job and click on Spool Push button.






In the Next Screen Select the Spool Number and click on Choose button.












Output for the background job will be displayed in the Next Screen.












If you would like to see the complete Job Log then come back to Job Details screen and select job Log option.








This displays the Complete detailed Log for this Background Job. 











Schedule a Background job in SAP ABAP (SM36)

To Schedule a Background job first Pre-Requisite is to create a Variant.

To Create a Variant, see below post:



Next step is to Create a Background Job:

GoTo SM36.

Give the Name of the Job and Press Enter or Click on Save.














A Pop-Up will be opened with Default User-Id and Job Name.

Select the Variant Name by using F4 help or by manually giving the name of the variant, and click on Save Button.

















Then Come Back to the Define background Job Screen, and select Start Condition.







In the Pop-Up click on Date/Time push button, and type in date and time at which you would like trigger this Job and then select Save Button.






















Click on Save Button.

After the Scheduled date and Time you can see the logs in SM37.


To View Processed Background Job logs, see below post:



How to Create a Variant in SAP ABAP

Below are the steps to Create a Variant in ABAP:

-> GoTo SE38 and enter the name of the Report for which you would like to create a Variant.















-> Click on Execute Button present on the Application Tool Bar.





OR

-> If you have created a Transaction Code just type the transaction code in Command Field.






Above steps will lead to Input Selection Screen

Provide the values in the Input Fields and Click on Save Button.















Give the Variant Name and Short Description














Select Option : 

Only for Background Processing - If you would like to run this Variant in background Mode, else if it is not checked it can be used for both Background and Foreground Mode.

Protect Variant - If you select this option, then Variant can be changed only by the person who created by it or last changed by.

Only Display in Catalog - If you select this option then the Variant name will not be appeared in the general input help but it will be available in Directory.

Click on Save Button. Variant is Created!!


Tutorial to Create Custom Text Editor in SAP ABAP

To Create a Custom Text Editor we will be using below Function Module: 'TERM_CONTROL_EDIT'.

Just copy paste below code in code editor and then Save, Check and Activate.

DATABEGIN OF textlines OCCURS 0,
      text(132TYPE c,
      END OF textlines.

*--FM for custom text editor
CALL FUNCTION 'TERM_CONTROL_EDIT'
  EXPORTING
    titel          'Demo for Custom Text Editor' "title
  TABLES
    textlines      textlines[]
  EXCEPTIONS
    user_cancelled 1
    OTHERS         2.


Save check and activate your code and press F8.

























To display title for your custom text editor pass text to Exporting parameter titel.

Whatever you are going to write in text editor will be saved in internal table textlines[].


How to Add Custom Text Editor in SAP ABAP

By using below FM we can create a Custom text Editor:

Function Module Name: TERM_CONTROL_EDIT

The structure of above FM looks like:

CALL FUNCTION 'TERM_CONTROL_EDIT'
* EXPORTING
*   TITEL                =
*   LANGU                =
  TABLES
    textlines            =
* EXCEPTIONS
*   USER_CANCELLED       = 1
*   OTHERS               = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


Mandatory fields for above FM is TABLES Parameter: TEXTLINES.

Related Links:



'SAVE_TEXT' Function Module in SAP ABAP

The purpose of this Function Module 'SAVE_TEXT' is to save text/data to a Text Object/Type in SAP.

The Structure of above FM looks like below:

CALL FUNCTION 'SAVE_TEXT'
  EXPORTING
*   CLIENT                = SY-MANDT
    header                =
*   INSERT                = ' '
*   SAVEMODE_DIRECT       = ' '
*   OWNER_SPECIFIED       = ' '
*   LOCAL_CAT             = ' '
* IMPORTING
*   FUNCTION              =
*   NEWHEADER             =
  tables
    lines                 =
* EXCEPTIONS
*   ID                    = 1
*   LANGUAGE              = 2
*   NAME                  = 3
*   OBJECT                = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


Description:

Mandatory fields for above FM are 'header' which is of type structure 'THEAD' .

To this structure or Workarea we have to pass these fields as mandatory: TDOBJECT, TDNAME, TDID, TDSPRAS.

See below post to find out above attributes for a given Text Type/Object.

"How to find the Properties/Attributes of a Text Object/Type in SAP ABAP"

Another Mandatory field is Tables: 'LINES' which is of type 'TLINE' having fields TDFORMAT and TDLINE.

The value for field TDFORMAT describes how the line is going to be stored in SAP.
Say: 
* -> for Default Parameter
= -> Continuous Text
Pass the text to be stored to the field TDLINE.
Note: Character size for TDLINE is only 132 characters, so if the string size is more than 132 characters split the string and add it to the next line by using TDFORMAT as '=" Continuous text.

Related Links: 



How to find the Properties/Attributes of a Text Object/Type in SAP ABAP

Below are the Steps to find the attributes of a Text Object/Type: 

Open the Text Type for which you would like to find the attributes, if text is already available then double click on the text editor(either in Change/Display mode). If text is not available then open the document in Change mode follow the below steps:

Double click on the Text Editor:

OR -  Just select Detail Button available at the bottom.




Below screen will be displayed, from here select GoTo option available on the Menu Bar and then select 'Header' from the the available options











Below Sub-Screen will be displayed with the Text Attributes:




















In the above screen Text Name is nothing but the Document Number, here I have considered Header Text if it is the Item Text then Text Name would be Document Number + Item Number.

Related Links: