Saturday, July 18, 2015

Check Statement

The CHECK statement checks a condition first inside a loop. If the condition is true then rest of the statements inside that loop will be executed. If the condition is false then the program controller terminates the current loop pass and it will go to the next loop iteration. Hence the condition is the prerequisite of CHECK statement. No condition will lead the syntax error of the program. Outside of the loop CHECK will leave the current processing block of the program.

REPORT  zabap_gui.

* Declaring the local structure of internal table
TYPES:
      BEGIN OF ty_tab,
        item     TYPE char10,
        quantity TYPE i,
        price    TYPE i,
      END OF ty_tab.

* Declaring the Standard internal table with non unique key
DATA:
      itab TYPE STANDARD TABLE OF ty_tab,
      wtab TYPE ty_tab.

* Entering records to each field
wtab-item = 'Rice'. wtab-quantity = 2. wtab-price = 80.

* Now one single row has been fulfilled with data
* Next appending one single row data into the table
APPEND wtab TO itab.

wtab-item = 'Sugar'. wtab-quantity = 1. wtab-price = 90.
APPEND wtab TO itab.

wtab-item = 'Tea'. wtab-quantity = 1. wtab-price = 100.
APPEND wtab TO itab.

wtab-item = 'Rice'. wtab-quantity = 3. wtab-price = 150.
APPEND wtab TO itab.

wtab-item = 'Horlicks'. wtab-quantity = 1. wtab-price = 200.
APPEND wtab TO itab.

wtab-item = 'Sugar'. wtab-quantity = 2. wtab-price = 70.
APPEND wtab TO itab.

* Sorting the itab by item.
SORT itab BY item.

WRITE:  /3 'Item',
        13 'Quantity(KG)',
        28 'Price(Rs)'.
WRITE / '=========================================='.
SKIP. " Skipping one single line

LOOP AT itab INTO wtab.

* If the condition is true then it will execute further statements
* If CHECK condition is false then it will move to the next iteration of loop
  CHECK wtab-item = 'Rice'.

  WRITE:  /3 wtab-item,
          12 wtab-quantity,
          25 wtab-price.
  CLEAR wtab.
ENDLOOP.

SKIP.
WRITE '=========================================='.






Whenever the check condition finds Rice item it goes to the rest of the statements of current loop. If the condition finds false (other than Rice) it leaves the current loop iteration and goes to the next loop pass.

16 comments:

Anonymous said...

HOW TO WRITE CHECK CONDITION IF I WANT TO CHECK BOTH SUGAR AND RICE.

Sandip Roy said...

We can simply use the OR clause here to fulfill your requirement. Try the following:

LOOP AT itab INTO wtab.

CHECK wtab-item = 'Rice'
OR wtab-item = 'Sugar'.

WRITE: /3 wtab-item,
12 wtab-quantity,
25 wtab-price.
CLEAR wtab.
ENDLOOP.

Anonymous said...

MR.SANDIP ROY thank you very much for your reply.

your blog is excellent very easy to learn for beginners its like spoon feeding. appreciate for your work.

once again thank you very much.

Anonymous said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Anonymous said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Anonymous said...

Informative Blog...For a long time I was craving for a career growth in programming and then I came to know that THE CREATING EXPERTS is the one who provide training with hands on training and real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact 8122241286

Unknown said...

Thanks for your info...Here THE CREATING EXPERTS provide hands on training with real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact +91-08122241286

Anonymous said...

Hi, I learned SAP Training in Chennai from THE CREATING EXPERTS. The training was good and i got selected in leading MNC company as SAP Consultant.

contact 8122241286

www.thecreatingexperts.com

David Miller said...

Wow, great post.

David Miller said...

You discuss about checking statement method. Must need this type loop for checking statement. I have read your post very carefully and try to understand this code. I also share a resource for your checking http://www.checkmypersonalstatement.net/nutrition-personal-statement/

Business World said...

Great information. the information provided is of great use as i got to learn new things. If you are looking for real time training in SAP ABAP, kindly contact sieve software
Sieve software offers real time training by industry experts with live projects and placement support.
SAP ABAP TRAINING IN HYDERABAD

NAINA said...

I see this is a great post. how old are you and how many year are you writing article http://www.lorwriting.com/writing-medical-school-letter-of-recommendation/ . I actually wanna know your skill.
Thanks

Anonymous said...

Good blog post, The those that wouldn't have the training and furthermore the data wouldn't have the capacity to rebuild or use the assets inside the best way amid which on this site those assets are regularly utilized for improvement of the nation.

best ideas here said...

you shares some good information about MBA Scholarships . ssat writing is very important in MBA admission hope your writing will help many students.

Unknown said...

I am so thankful for your blog.

ananthinfo said...

nice post..ERP for leather solution