Tuesday, July 31, 2007

Making Money Online

Wouldnt it be nice if you were paid to do something you do as part of
your everyday routine ?? Like searching the web

Sounds too good to be true .. doesnt it ..

At first i was skeptical about it , but after seeing the results , thought i will share the information.
You should try it to believe it ...

SlashMySearch pays you to use their search engine...

Use SlashMySearch as your primary search engine and earn ....

The best part is joining is absolutely free...
You do not have to install any software or go through long guides.
All you need to spend is 2 minutes to get started.
There is also a referral program. You get pais for your referrals' activity ...

What are you waiting for
Join Now ... Hurry Up..
Please use the below link. In this way both u and i will be benefitted.

http://www.slashmysearch.com/earn/signup.html?id=57034

In case you have any doubts , feel free to ask questions.

Friday, June 29, 2007

How to debug a background job

At times you might find yourself in a situation to debug background jobs.
Is it possible in SAP?? Yes it is ...

There are two ways to achieve the same.

1) Goto sm37 (Job overview ). Select the job you want to debug , enter JDBG in the OKCODE.
This can be used to debug any process.

2) Code an infinite loop in your program at the point where you want to debug.

ex

do
if i=1
exit
endif
enddo.

Start the program.
Goto sm50 ( Process overview ). The process appears in the running state and then goes to hanging state.
click on the process.
Goto Program/mode -> program -> debugging.

Change the value of i at runtime in the debugger.

How to run sap sessions

After all the hustle bustle , u created a session ... Good Job ...

To process it you need to go to transaction sm35 , and then start the session.
Isnt this too much of work in real time ...

There is an easier way to handle sessions.

The program RSBDCSUB executes sessions that have not yet been processed.
This program can be scheduled periodically in the Background Jobs ( sm36).

There we go ..

Restarting Interrupted Sessions in SAP

sm35 is the transaction code for batch input sessions.
A session that was interrupted while it was running will be in the Active state.
To retsart the session it must first be released.
Click on the session and select relese from the toolbar.

You can then start the session.
All transactions that were completed sucessfully during the previous run will be
skipped.
The transaction that was getting executed while the problem ocurred will be
repeated.

If the generation of the session itself was interrupted , it will be in
Being generated state.

You can run such a session.
But there is no gurantee that it has all the transaction information.
So in this case it is best to recreate the session.

Wednesday, June 27, 2007

Understanding BDC call transaction

Lets derive the BDC process...

The aim of BDC is to transfer data from flat file ( or xls ) to the appropriate database tables in SAP.

To transfer data into the DB tables , an internal table should be used in the program.

Here we go to our first step

1) Declare an internal table with relevant fields.

How do u transfer data into your internal table from the flat file.
We have a function module gui_upload for this purpose.
This is our next step

2) Upload data from flat file into the internal table.

Now we have data in our internal table , we need to transfer it to the DB tables.
SQL is an option but is not advisable because a single transaction affects more than one table.
Hence SQL is not a safe way of transferring data.

So whats the other way to accomplish the same.
We are all aware that transaction codes exist for the creation of data.
Ex xk01 is the code for creating a vendor master data.

Transactions can be called from the program using CALL TRANSACTION 'TCODE'.

Now, the above statement causes opens a new transaction and one has to manually
enter data. This defeats the whole purpose of BDC. There should be a way to automate the process of enterring data.

Well, there is a way to automate the process.

CALL TRANSACTION USING
MODE UPDATE MESSAGES INTO

is used for the same.

Dont panic .. you will understand the syntax once u understand the logic.

Since we want to automate the data entry process in the transaction, there should be some
means by which the transaction receives data t be entered.
BDCDATA holds the data and actions to be performed to complete the transaction.
For example , to comple a transaction , one might have to go through a sequence of screens , entering values in the fields.
This sequence and data is stored in BDCDATA structure.

To explain in very simple terms , BDCDATA tells the system what it should do in that transaction.
For ex. the contents of a typical BDCDATA structure for xd01 translates to

"Fill value for customer,sales organization, distribution channel ,
then move on to screen 1020.
In screen 1020 fill values for name , search term ...
Then move on to screen 1030"

Phew...

Ok now u r happy that this BDCDATA does some magic and gets the system to fill values in the transaction.
Remember in programming there is no magic , what u ask the sytem to do is what u get ...
Someone has to fill the BDCDATA structure.
In my previous blog i have explained BDCDATA in detail.

Filling the structure manually is a big pain ...
There is an easier method to do it ...

IN SAP there is a concept called "Record transaction" ..
Goto shdb , start new recording , enter the transaction code that u want to record ,
keep filling values , save the recording...
All actions that u performed throughout the entire transaction is stored.

Now goto edit , create program. This creates a program with information about the recording.
Copy the list of performs used to fill the bdc data.
This list populates the structure BDCDATA.
You dont have the headache of populating it urself ..

I guess the remaining steps will fall into place now..

3) Process itab
4) For each entry of itab create a bdcdata structure with field values from the itab.
5) CALL TRANSACTION USING
MODE
UPDATE MESSAGES INTO
6) check sy-subrc and process errors.

Tuesday, June 26, 2007

UPLOAD data from Excel to Itab

The function module
ALSM_EXCEL_TO_INTERNAL_TABLE is used to migrate data from an excel file
into an internal table.

The internal table should be declared of type ALSMEX_TABLINE.

This structure has the following fields

ROW COL VALUE.

Each cell of the excel data is stored as a record in the table.

BDCDATA structure in depth

BDCDATA structure stores the data that needs to be transferred to the SAP system.

The structure has the following fields.

PROGRAM
Name of the program.

DYNPRO
Screen Number

DYNBEGIN
Marks the beginning of a screen in a transaction

FNAM
Field NAme

FVAL
Field value.

The records can be divided into screen records and field records.

Each screen of the transaction is assigned a row in the BDCDATA structure.
This row contains Program,Dynpro and Dynbegin fields.
Dynbegin is set to 'X' to mark the beginning of the screen.

A record is assigned for each of the values entered.
These field records have only FNAM and FVAL.

The function codes of commands entered during the transaction are
entered in the structure too.