Tuesday, June 28, 2011

Tutorials on LSMW

1. Uploading Vendor Master Data using Direct Input Method


2. Uploading Vendor Master Data using Recording Method


3. Migrating Customer data along with relationships (CRM)


4. Step-By-Step Guide for LSMW using ALE/IDOC Method

5. Uploading Purchase Info records using IDOC Method

6. Migration of Bank data using BAPI in LSMW

7. Using BAPI in LSMW (Uploading PO data)

8. Uploading Material Master data using BAPI method

9. Uploading Material Master data using Recording Method

10. Update Customer Master records using Batch Input

11. Uploading Material Master records using Direct Input Method

12. Differences between LSMW and BDC

13. Copying LSMW object from one client to another

14. When Standard BAPI has to be modified for using in LSMW

15. Using routines and exception handling in LSMW

16. Validations in LSMW

17. Uploading long text for Material Master 'Purchase Order Text"

18.Handling multiple recordings in LSMW




19. Creating Normal program (BDC, ALV Report) by using LSMW in non-development clients

ALV Tutorials

Tutorials on BAPI

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro)


eCATT (extended Computer Aided Test Tool)

Userexits/BADIs

Business Server Pages (BSP)

SAP Query

Tutorials on Object Oriented Programming(ABAP)

Adobe Interactive Forms Tutorials

ABAP Interview Questions

SAP Enterprise Portals (EP)

Tutorials on SAP-ABAP

Tutorials on SAP Data Dictionary

Friday, June 3, 2011

Scheduling Background jobs

Objective: Scheduling a background job in SAP R/3. These document intents to provide steps which can be done even by an end user to prepare a Job.

Main Steps:

1. Change screen layout of stock report as per the requirement.

2. Create variant to run the stock report (MB52) via Job.

3. Access transaction code SM36 to create the Job.

4. Monitor the Job and check the spool

5. Access SAP Business Work place to check the Spool.

Step1: Create Screen layout

Assumption: Go to transaction MB52 and enter the value of the Plant (let’s say 1000).

Step : Create Variant along with the layout which we have created in previous step.

Press F4 on the layout field in initial screen and then press save.

After selecting the layout here please click on save.

Step: Please mention the variant name as per your choice and also mention the description.

You may also mark the check box protect variant for the field plant and layout though its not mandatory.

Save

Step: Finding the program name for transaction code MB52

Now please notice the Program name RM07MLBS.

Step: Log in transaction code SM36.

Mention the Job name as ZDaliystk_MB52_1000.

Press enter to get the below screen



Click on the ABAP program and mention the program and also select the variant name which was created in initial steps.

Click on check and save

Step : Now click on the start condition button.

In this step we are giving the frequency of running the job. As already mentioned the Job needs to run daily basis.

click on the period values button and also mark the period check box as the job has to run every day.

Click on the spool recipient button

Just press enter and save to get the message that job is in release status

Monitor and check the output of job. Access transaction code SM37.

Also mention the Job name

execute and check the spool.

click on the type

Step: Here we are with the results which is list of stock in our case



Converting an XML file with many hierarchy levels to ABAP format

This example shows how we can convert an XML file with many hierarchy levels to ABAP format.

Copy and paste the following code in notepad and save it as test.xml file.

Save the XML file which in desktop or some other path

            0000000000038491     ZEU_MATMAS           004     000000000000010003          005      E      promo pack normal      EN           

Here we can see that the root node is ZEU_MATMAS03 which is the main structure containing all other structures.

It contains IDOC structure which in turn contains E1MARAM and EDI_DC40 structures within.

EDI_DC40 contains DOCNUM and MESTYP fields.

E1MARAM contains E1MAKTM structure and MSGFN and MATNR fields.

In SAP we have to create corresponding structures to store this data from XML to ABAP.The main structure contains many deep structures.

So in ABAP dictionary we first create the structure ZIDOC_TEST which contains Structures ZEDIDC40 and Z1EMARAM_TEST1.

ZIDOC_TEST structure contains ZE1MARAM_TEST1 and ZEDIDC40 structures within.

ZEDIDC40 contains DOCNUM and MESTYP fields.

ZE1MARAM_TEST1 contains E1MAKTM structure and MSGFN and MATNR fields.

The structures Z1EMARAM_TEST1 and ZEDIDC40 are also created as shown in the below slides.

This is the structure of ZEDIDC40 - Control record with fields DOCNUM and MESTYP..

The structure ZE1MARAM_TEST1 contains the following fields MSGFN and MATNR.Also a deep structure E1MAKTM.

E1MAKTM Structure is a standard dictionary structure we are using directly with the fields MSGFN,SPRAS,MAKTX and SPRAS_ISO.

The following ABAP program converts the given input XML file to ABAP format.

TYPE-POOLS abap.

*Input file contents as string.XML file path where we saved the file. *Here it is saved in desktop.

*Input file with path as constant
CONSTANTS gs_file TYPE string VALUE 'C:\Documents and Settings\Administrator\Desktop\test1.xml'.

*This is the structure type for the data from the XML file
TYPES
: BEGIN OF ts_zeu_matmas03,
idoc
TYPE ZIDOC_TEST, “ZIDOC_TEST structure we created in SE11
END OF ts_zeu_matmas03.

* Table for storing the XML content from file
DATA: gt_itab TYPE STANDARD TABLE OF char2048.

* Table and work areas for the data from the XML file
DATA: gt_zeu_matmas03 TYPE STANDARD TABLE OF ts_zeu_matmas03,
gs_zeu_matmas03
TYPE ts_zeu_matmas03.

* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml
TYPE abap_trans_resbind.

* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text
TYPE string.

* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error =
1
file_read_error =
2
no_batch =
3
gui_refuse_filetransfer =
4
invalid_type =
5
no_authority =
6
unknown_error =
7
bad_data_format =
8
header_not_allowed =
9
separator_not_allowed =
10
header_too_long =
11
unknown_dp_error =
12
access_denied =
13
dp_out_of_memory =
14
disk_full =
15
dp_timeout =
16
not_supported_by_gui =
17
error_no_gui =
18
OTHERS = 19.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

* Fill the result table with a reference to the data table.
* Within the XSLT style sheet, the data table can be accessed with
* "IDOC_GET".

GET REFERENCE OF gt_zeu_matmas03 INTO gs_result_xml-value.
gs_result_xml-name =
'IDOC_GET'.
APPEND gs_result_xml TO gt_result_xml.

* Perform the XSLT stylesheet

TRY.

CALL TRANSFORMATION z_xml_idoc
SOURCE XML gt_itab
RESULT (gt_result_xml).

In this part of the code

Z_XML_IDOC should be created in XSLT Editor and write code for that as follows:-

We can go there by double clicking on Z_XML_IDOC.Create it and after copying this code activate it.

XSLT is a language is used to convert XML from one format to another format.

Copy paste the following code in XSLT editor :-

Some rules which were applied for conversion to XSLT are:-

IDOC_GET is used to get the data from IDOC.In the XML file the main node is IDOC which has E1MARAM and EDIDC_40 which in turn contains MSGFN,MATNR and E1MAKTM and EDIDC_40 contains MSGFN and DOCNUM respectively.

The same type of structure which is used in our program needs to be filled.In our program EDIDC_40 is used as ZEDIDC40 and E1MARAM is used as ZE1MARAM_TEST1.

The basic template is already filled when we enter the XSLT editor.

We use IDOC_GET to use the IDOC data.We should use the tags to be filled in the hierarchy structure as we declared it in the program.To use the values we need to use the structures in the XML file.Use the corresponding path to access the values.

After transformation the gt_zeu_matmas03 is filled which can be used for displaying.

      
                                                          
                                                                                                                                                                               
    

*Come back to ABAP editor and copy this code for error handling.

CATCH cx_root INTO gs_rif_ex.

gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.

ENDTRY.

*Display the file contents on screen.
IF
sy-subrc = 0.
LOOP at gt_zeu_matmas03 INTO gs_zeu_matmas03.
WRITE: gs_zeu_matmas03-idoc-zedidc40-docnum, “document no
/ gs_zeu_matmas03-idoc-zedidc40-mestyp, “message type
/ gs_zeu_matmas03-idoc-ze1maram_test1-msgfn,”message function
/ gs_zeu_matmas03-idoc-ze1maram_test1-matnr,”material no

*all fields of E1MAKTM segment
/ gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-msgfn,
/ gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-spras,
/ gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-maktx,
/ gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-spras_iso.
ENDLOOP.
ENDIF.

We can see the values filled in the heirarchy structure of IDOC as follows:-

Execute the ABAP program and we get the file contents displayed as below.So we have converted the given XML File to a structure and display the contents.

Final output of the program is:-



Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

goodsites