ABAP log

October 10, 2007

Navigating component screen of CO02 with BDC.

Filed under: ABAP, SAP — abaplog @ 8:10 pm

Creating and changing production orders in SAP R/3 is a common task in production planing. While you can easily create an order from your ABAP program and do some simple changes using BDC technique, things get ugly when you need to do some more complex tasks. Unfortunately, there are no BAPIs or official function modules to cover every possible operation. Creating orders and changing their operation parameters can be done using “Production Optimization Interface” functions, as I described once here on ABAPlog. Yes, we all know that a couple of years ago SAP promised us to cover complete functionality of SAP with its SOA stuff (ESA in SAP lingo) till the end of 2007, but it doesn’t look like they are going to hit that. Therefore, we poor ABAP developers have to stick with BDC as the last but proven solution.

The most common requirement, apart from changing the header and operation data, is changing the component list. This could be relatively easy with BDC, but only if you are always sure that you have just a few of components that fit on the same page of the table control in the component overview of CO02. Unlucky ones have to deal with the navigation. Some general ideas are given in the BDC article of the ABAP Knowledge Corner from Richard Harper. The main point is: look for navigation commands in menu. Even if you don’t see them, you still have a chance that they are not present in the GUI status but nevertheless supported (you have to study the source code of the SAP transaction to find that out). But CO02 have a wonderful command in its component overview screen: “Find”. Clicking it brings a popup window:

co02.gif

For BCD, it’s the screen 0110 of the program SAPLCO05. By filling some parameters and clicking Enter, you land on the corresponding line. This line will be the first one in the table control and thus easily handles by your batch input. Before using the navigation screen, it is normally a good idea to navigate to the top of the list using the corresponding command.

Let’s see how can we use the navigation. I assume first that each ABAP BDC program defines a form to populate BDC data table, something like this:

form dynpro using dynbegin name value.
  if dynbegin = 'X'.
    clear t_bdc_tab.
    move: name                    to t_bdc_tab-program,
          value                   to t_bdc_tab-dynpro,
          'X'                     to t_bdc_tab-dynbegin.
    append t_bdc_tab.
  else.
    clear t_bdc_tab.
    move: name                    to t_bdc_tab-fnam,
          value                   to t_bdc_tab-fval.
    append t_bdc_tab.
  endif.
endform.

The following form will change the sort string (normally the very last column) for item identified with position number and material:

form change_sort_string
  using p_pos p_newsortval p_matnr.
  perform dynpro using:
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_OKCODE' 'P--',  "Go to top pos first
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_OKCODE' 'AUFS',  "Find item
    'X' 'SAPLCO05' '0110',
    ' ' 'RCOSU-POSNR' p_pos,
    ' ' 'RCOSU-MATNR' p_matnr,
    ' ' 'BDC_OKCODE' 'MORE',  "Enter to navigate
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_CURSOR' 'RESBD-SORTF(01)',
    ' ' 'RESBD-SORTF(01)' p_newsortval,
    ' ' 'BDC_OKCODE' '/00',  "Enter to change pos number
    'X' 'SAPLCOMD' '0110',
    ' ' 'BDC_OKCODE' '/00'.  "confirm
endform.

And this one will delete the item, also identified with its position number and material:

form delete_pos_by_number using    p_posnr p_matnr.
  perform dynpro using:
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_OKCODE' 'P--',  "Go to top pos first
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_OKCODE' 'AUFS',  "Find item
    'X' 'SAPLCO05' '0110',
    ' ' 'RCOSU-POSNR' p_posnr,
    ' ' 'RCOSU-MATNR' p_matnr,
    ' ' 'BDC_OKCODE' 'MORE',  "Enter to navigate
    'X' 'SAPLCOMK' '0120',
    ' ' 'BDC_CURSOR' 'RESBD-POSNR(01)',
    ' ' 'RC27X-FLG_SEL(01)' 'X',  "select 1st item in the list
    ' ' 'BDC_OKCODE' 'DEL',  "delete selected item
    'X' 'SAPLCOMD' '0110',
    ' ' 'BDC_OKCODE' '/00'.  "confirm
endform.
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: