Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
laurent_fournier2
Contributor
0 Kudos

Hello everyone,

The reason I decided to write this post was the post of a user in SCN about a commonly seen batch input error ( No batch input data for screen xxx yyy ).

I tried to help the user pin point the problem and correct it but with no luck. But, I realized that If the code was written with a different and more structured way, it could be more easier for me or even for the user himself to identify and correct the error. Let me please explain what I mean :

The user has posted his code in the forum that in general was something like this :

   perform bdc_dynpro      using 'SAPXXXX' '0100'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'XXX-XXX'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/XX'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   perform bdc_field       using 'XXX-XXX'

                                 'YYY'.

   LOOP AT ZZZZ ASSIGNING <ZZZZ>.

     perform bdc_field       using 'XXX-XXX'

                                   'YYY'.

     perform bdc_field       using 'XXX-XXX'

                                   'YYY'.

     perform bdc_dynpro      using 'SAPXXXX' '0300'.

     perform bdc_field       using 'BDC_CURSOR'

                                   'XXX-XXX'.

     perform bdc_field       using 'BDC_OKCODE'

                                   '/XX'.

     perform bdc_field       using 'XXX-XXX'

                                   'YYY'.

     perform bdc_field       using 'XXX-XXX'

                                   'YYY'.

     perform bdc_dynpro      using 'XXX-XXX' '0102'.

     perform bdc_field       using 'BDC_CURSOR'

                                   'XXX-XXX'.

     perform bdc_field       using 'BDC_OKCODE'

                                   '=XXXX'.

     perform bdc_field       using 'XXX-XXX'

                                  'YYY'.

     perform bdc_field       using 'XXX-XXX'

                                  'YYY'.

     perform bdc_field       using 'XXX-XXX'

                                  'YYY'.

     perform bdc_field       using 'XXX-XXX'

                                  'YYY'.

As you can probably see, In the above piece of code, it's not easy to understand when a screen ends, when a new screen starts and the whole process logic in general, so especially if you don't have access to the system and trying to help a user identify a problem it's not very easy to understand and try to pin point the problem by using the above mentioned snippet.

In general, The person who helped me when I was in my first steps of my career back in 1998, taught me to always write clear and structured code so that it can be easily maintainable and readable even from another person.

So, If I was assigned to write the above mentioned batch input, I would probably write something like this :

* --- First Screen - Document Header data

  perform bdc_dynpro      using 'SAPXXXX' '0100'.

  perform bdc_field       using 'BDC_CURSOR' 'XXX-XXX'.

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'BDC_OKCODE' '/XX'.

* --- Second Screen, Enter Line Items

   LOOP AT ZZZZ ASSIGNING <ZZZZ>.

  perform bdc_dynpro      using 'SAPXXXX' '0300'.

  perform bdc_field       using 'BDC_CURSOR' 'XXX-XXX'.

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'BDC_OKCODE' '/XX'.

* --- Enter Details For Each Item

  perform bdc_dynpro      using 'SAPXXXX' '0102'.

  perform bdc_field       using 'BDC_CURSOR' 'XXX-XXX'.

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'. 

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'XXX-XXX' 'YYY'.

  perform bdc_field       using 'BDC_OKCODE' '/XX'.

I prefer,when writing batch input programs to start every new screen with the form "BDC_DYNPRO" insert all the fields that I want to pass and add a "BDC_OKCODE" in the end. With this way, it will be very easy to identify and resolve any problems related to the batch input since each processing block is clearly defined and I could easily lets say combine each screen of the transaction with each block of the code when running/viewing in parallel ( mode a ) in order to find the error.

I know that everybody is used to write programs with an own unique way.The above example applies not only for batch input programs but of course in general.Writing with a clearly and structured way, not only will help you to resolve easier any kind of bugs but also can help us to identify any kind of problems and try to propose the solution in the forums.

Regards,

LF.

6 Comments