Blog 1: Your First SAP BDC Code (Step-by-Step)
SHDB in the command box. By the end of this post, you will own a piece of ABAP code that fills SAP screens automatically.
In this blog, we are going to do something cool. We are going to teach SAP to do our work for us. We will use the Transaction Recorder.
It’s like a voice recorder on your phone, but instead of recording your voice, it records your mouse clicks and keyboard typing inside SAP.
The SHDB Recording Overview screen
Look at the top left and click the button that says New recording.
Step 1: Start the Recorder
A small pop-up window will open. It should look exactly like this:
The Create Recording window
- Recording: Type
Z_MY_FIRST_BDC - Transaction code: Type
MM01(This is the SAP screen used to create a new material/item. We will use this to practice.) - Leave everything else exactly as it is.
- Click the Start recording button.
Step 2: Do the Work Manually
Now, we pretend to be a normal SAP user. We will create a material by hand. SAP is watching and recording everything we do.
Step 3: Turn Your Clicks into Code
When you exit, SAP will take you back to the first screen (the list of recordings).
- Look at the list. You will see your new recording:
Z_MY_FIRST_BDC. - Click the small gray box next to it to select it.
- Click the Program button at the top.
- SAP will ask for a name. Type:
Z_MY_FIRST_BDC_PROG. - Choose Transfer from recording. Click the green checkmark and save it.
SAP will now show you a screen full of text. This is ABAP code!
The Magic Check
Scroll down in the code until you see words that look like this:
perform bdc_field using 'RMMG1-MATNR' 'ZTEST-001'.
Your Task: Look at the first line that starts with perform bdc_field. See the word inside the very first set of quotes? (It will probably be RMMG1-MATNR).
Think about it: Why did SAP write that specific word? Because when you typed “ZTEST-001” into the screen, SAP wrote it into the code. Your clicks became code!
Revision: What did we just learn?
Click the question below to reveal the answer. Try answering it out loud before you click!
Why is the code we just generated considered “dumb” or “hardcoded”?
ZTEST-001. If you want to upload 500 materials, this code will just create ZTEST-001 500 times. It cannot read new data from a file yet.
What is the purpose of Transaction SHDB?
What’s Next?
In Blog 2, we are going to make this robot smart. We will teach it to read a text file on your computer and upload 500 materials in one click.
Homework: Make sure you saved your program Z_MY_FIRST_BDC_PROG. See you in Blog 2!
WhatsApp us