Program 2 - Stock list ( Part 1 )

Siva Prasad
A free video tutorial from Siva Prasad
SAP Trainer and Consultant
4.4 instructor rating • 10 courses • 91,766 students

Lecture description

In this lecture we talk about a couple of things

1. WRITE statement - How to write Horizontal and Vertical Lines

2. WRITE Statement - How to write at a particular offset location

3. WRITE Statement - How to write in a new line. 

4. DO - ENDDO loop.

5. Declare DATA variables

6. Default values to variables

7. Use of TYPE to declare data variables. 

Learn more from the full course

SAP ABAP Training - in Plain English

ABAP for absolute beginners - No Programming knowledge required

18:30:01 of on-demand video • Updated August 2018

  • Write ABAP Programs
  • Interpret existing ABAP programs
  • Be conversant with most major programming constructs and paradigms, specifically Enterprise Application programming
English [Auto] OK let's move on to our second program is just what is a stock list. Imagine a Cartier car dealer. And nobody wants to know how much stock of cars he has. Meaning if it is a Ford dealer how many Ford paresis do I have. How many Ford endeavors. How many Ford SUV Do I have. How many Ford. Right. So how is it going to look like you're going to look at the transaction. I mean be underscore old and an entitlement material say 0 1. This could be for example to make a car for us. It acute. It's going to show you this report the voodoo format. So this material in it all one has a stock of 2134 But there's this very elaborate very fancy will not be able to do it at this point. But what we're going to do is create something that's really very simple. All right. The stock list the board is going to show a set of columns like this and it's going to say to you in court. That's all we need for now. And then material one will read into material 3 and then repeat L-1 quantities. Hundred one hundred or whatever right. Get the point. So how do you like this program. Who is the 38 in one to start with the easy well underscore the second problem. Then underscore stock underscore just the concrete you lock stock list. And it's going to be an executable program. Click on see and click on local object and then you go basically a blank screen. OK. So here is what I'm going to do. We're going to create this section first. Box disappeared. And then the postbox is going to say you do the second box is going to see Corti look in order to do that. We have two reviews right. Steve Holligan redo the. Awfully difficult but it was a bit of patience in being able to deal with right. Because the live statement has so many options. And building this box using the right statement is a bit tricky but not very difficult. The vertical line will be created using the pipe OK. This is typically right about your Enter depends on the type of keyboard that you have read something that looks like what tickle my OK you won't have to use your shift key for that. And these horizontal lines are Creator by dashes or hyphens not underscores but hyphens so what they're going to do is step one like this line. OK. Using you know let's say 20 dioecious then right underneath that the lane or a pipe OK and then say repeat. And then right after that we'll do another pipe OK and then say I want to be liked in quantity and then when this is what another pipe and then in the next line do the dashes that should complete our box and then the words inside it. Let's do it. So right then it's going to be single chord on that a bunch of dashes right and then sénéchal it again. But what's it going to do is you get this b c it doesn't show you the dashes breaks and it shows you it an entire line seems like it's going to automatically do that conversion. OK so we don't know how great a horizontal we go back then. You've got to work a pipe get it right. So this is our pipe character right. And then we need. This is a man Lynsay T. Want now executing it. What does it say. It puts your material in the same line. It doesn't come back to the next line. Because we want the material somewhere here. We want that word Pick a lane here not here. So we've got to force SFP to move the next OK way to do that ease with Slash play so you can do white slash that say move to the next line. Right. OK then you've got the pipe here but these two things are not joined together. So we need the wire lane to join the horizontal. So instead of doing this what you can do is you can put a lane here like a slash there and it pushes this lane to the next line. So if you try to execute it like this you see that the line is going to be aligned properly with the horizontal line. Now what if you don't understand this it's ok. You know we're trying to just play with the rights stuff you know do horizontal lines typing characters songs OK then what does you want to do. We also want to write another play so you can go there and put in some spaces and then work on other people OK and then put in some spaces and you can see quantity and small spaces and then you can put another pipe and close that string right. It's good that again. OK. It's getting close. You just need to push this pipe pretty good line. Probably one more space. Right. And they do that just do another space trainings you get it. Is it aligned. Yes it is. Right. So go back and do another. Right. You want to take this entire Adeline Control-C go down and then control the great cute and then of course we have to put the slash right so go back and then sort of slash here like so and execute again. Did you get a box box with the Sopranos and then mysterium to the left in quantity right. OK. And underneath that you need the list of materials in quantity here. Right. How do we do that. Well you know how to create these were the Galanes. Right so I'm not going to bother too much about it. I'm just going to focus on how right in the materials you can have pen. We're going to have hundred materials. Now we don't have a list of those materials. I ate all the quantities yet. So what I'm going to do is I'm just going to write something here with detail 1 1 1 1 1 and then quantity hundred hundred hundred hundred all the way 20 days. How do we do that. OK go back. So you want to repeat an action 20 times or 30 times 100 times you can do it with something called a blue and number of times. In this case you only do 20 times OK Dudely times you're taling about something really times what you wanted. You want to say right say one just one desmo And then after a bunch of space like say a hundred coordinates and something of this white one and then this is the column on the left and then right. Hunger This is the color right. OK. Then after you are done doing whatever logic you want to do times you've got to end this do because it has to in some so that use what is called an. Right. So SEPs pumping you. So when a piping indeed you see this little pop appear in the right. See this didn't pop up. That's a suggestion about it suggesting you saying hey do you want to use this statement and do looks like you got a blue upstairs here and you might want to end this. If not you could be writing something else it's justice. So what I'm going to do is in due once that little pop up comes up you could type in your Pab and then SFP automatically. What's the suggestion right there. Without you having to type it. And then and blue dot the DOT is going to end up. So do porny times where do I have to do I right 100 and then and do. So the program is well basically loop over these two wins times. Anything between the do and do look at what do you types see that works. So cute. OK. It goes on in the horizontal direction but at the end of every 100 you want to look back to the next line right. So go back then typing right slash right. Well let's try these again. So cute. OK. Sounds about right. But we don't want hundred here. I would rather have it here. Right. You need quantity right. So. So you want to push this hundred below quantity to the right way to do that. There are multiple ways to do it. One way is like this. Right. OK. Right say 15 is and then the string hundred right. Let's see what happens. You see that hunger. This column is being pushed to the like how much the right 15 characters. That's because you mentioned 15. So using that right and number of columns and then something else you can write at a specific location. Right. Now let's make this a little more interest. Now we don't want to just do 1 1 1 1 1 1 1 right. Want say at least say one two three four five six seven eight nine ten right. We don't have the data for the materials yet but at least when I do the right one will face it. So when I think Hardy to let Well again many ways to do it we're going to do it a very simple you're going to declare it really we'll talk about it. What it will do that is with the key word data so data then we're going to do an isolation rate. So we're going to say times all it could do something like the underscore times just to make yourself clear that this is a bit of a variable not a keyword like times. Although there's no collision it's easy to put the underscore Pinos or something like that to differentiate the fact that this is a different kind of variable. Then what is it going to hold. We are defining a variable. Your variable is like a box. The meta what kind of box is it. You know not every box can hold everything. Right. What we want to store here is something that works in number. So we wanted a one two three four five six seven eight nine ten. Right. So that's numbers. So this is of type. This box is going to go on horror something of a type in teacher and we're to declare that is missing. It's a type I I just OK. Now instead of writing one next right the underscore times whatever is in that box now executed. What happens. It says zero. Right. The reason is you have just declared a box B underscore times where it didn't put anything in it it did not initialize the variable or it did not put anything in that box. So go back and say type I want you say what. So you're giving it a value putting one in. OK. So if you don't put anything in an integer box or integer variable it's going to default to zero. Or they can put any relevant value on executive. Now everything is a worm. But that's not what you want to play. You aren't one of them. Two and them three four four. So all you have to do is increment is the underscore times equals the underscore times. Plus one simple right you're adding one object and every time this loops through the second time the second goes here. The third time it goes here it's incremented by 1. Let's see if that works. A CUTE. It works. One two three four five. All the way up to 20 because you've asked it to do it just 20 times. That you could do the same for quantity. The point being they want you to understand what isn't really how you define a particular kind of evil it could be an integer. It could be a string of characters could be a single character. It could be a floating point. We're going to talk about that later. But essentially what it is how to do or how to specifically light on a particular column and how to do things and number of pipes 50 times hundred times any number of things. OK. So we do a great horizontal and vertical lines you know how to right at a specific location. Ali outproduce right. Pain which starts rating at the temp column and then whatever the one we know how to do a new line. All you have to do is put up forward slash you know Holker declare it as an idea. Really Evil is like a box that can hold. In this case that box is hoarding an integer. You have to define that it's of typing. Then we have seen how to read anything. Any number of times using the do an end to Giusti So everything you put in between do an undo gets repeated as many number of pipes and then we have seen how to do an addition right. We have incremented the code of the table and number of times.