Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP : How to select a line in a table control

Former Member
0 Kudos
1,470

Hi everybody,

I have a multi-item Contract (2 items: item 10 and item 20)

I store the contract items informations in an internal table wt_ha

I want to call a transaction that can assign the quantity of an order item to contract items.

Here's the code :



LOOP AT wt_ha

CONSTANTS :
  c_fnam1  TYPE BDCDATA-FNAM VALUE 'CONTRACT_VBAP-SELKZ(',
  c_fnam2  type BDCDATA-FNAM value 'CONTRACT_VBAP-POSNR(',
  c_close  type C      VALUE ')'.


  wa_sytabix = sy-tabix.
  concatenate c_fnam1 wa_sytabix c_close into wa_champ1.
  concatenate c_fnam2 wa_sytabix c_close into wa_champ2.

* Transaction VA42                                      
  PERFORM bdc_dynpro      USING 'SAPMV45A' '0102'.

  PERFORM bdc_field       USING 'VBAK-VBELN' wt_comm-vbeln.

  PERFORM bdc_field       USING 'BDC_OKCODE' '/00'.

  PERFORM bdc_dynpro      USING 'SAPMV45A' '4001'.

* Action : Assign an item
  PERFORM bdc_field       USING 'BDC_OKCODE' '=APPL'.

  PERFORM bdc_field       USING 'BDC_CURSOR' 'VBAP-POSNR(01)'.
  PERFORM bdc_field       USING 'RV45A-VBAP_SELKZ(01)' 'X'.

  PERFORM bdc_dynpro      USING 'SAPLV45C' '0103'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=ZUOR'.
  PERFORM bdc_field       USING 'LV45C-VBELN' wt_ha-vbeln.

  PERFORM bdc_dynpro      USING 'SAPLV45C' '0900'.
  PERFORM bdc_field        USING 'BDC_CURSOR' wa_champ2.
  PERFORM bdc_field        USING  wa_champ1 'X'.

  PERFORM bdc_field       USING 'BDC_OKCODE' '=ANWD'.
  PERFORM bdc_dynpro      USING 'SAPMV45A' '4001'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=SICH'.

  CALL TRANSACTION 'VA02' USING bdcdata MODE 'N' UPDATE 'S'
                                        MESSAGES INTO wt_mess.


ENDLOOP

The problem is that even if the internal table wt_ha contain 2 items, this programm can assign the order item quantity to only the FIRST contract item !

1 ACCEPTED SOLUTION

Former Member
0 Kudos
392

Hi,

You need to handle Table Control in BDC

Refer the link:

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

The concept is easy: it has to indicate the index of the table control in the field name, so if you have to populate the first record of table control:

BDC-FIELDNAME = <FIELDNAME>(01).

If you fill the second row:

BDC-FIELDNAME = <FIELDNAME>(02).

and so....

Now the problem is usually on how many records you have to load, because u can fill only the rows of table control available in the screen, If you have more records than it can be displayed yuo have to simulate the command to go next page.

The number of recod can be displayed can depend on pc resolution and many program haven't command to go to next page (in this case it could be impossible create a BDC program9.

A way to create a bdc program resolution indipendent is to work on the first and second row.

- Place the first hit in the first row of bdc;

- Place the second insert in the second row of bdc;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- .... and so

For more info: Search in SDN with TABLE CONTROL IN BDC.

Will get a lot of related links.

Reward points if this Helps.

Manish

2 REPLIES 2

Former Member
0 Kudos
393

Hi,

You need to handle Table Control in BDC

Refer the link:

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

The concept is easy: it has to indicate the index of the table control in the field name, so if you have to populate the first record of table control:

BDC-FIELDNAME = <FIELDNAME>(01).

If you fill the second row:

BDC-FIELDNAME = <FIELDNAME>(02).

and so....

Now the problem is usually on how many records you have to load, because u can fill only the rows of table control available in the screen, If you have more records than it can be displayed yuo have to simulate the command to go next page.

The number of recod can be displayed can depend on pc resolution and many program haven't command to go to next page (in this case it could be impossible create a BDC program9.

A way to create a bdc program resolution indipendent is to work on the first and second row.

- Place the first hit in the first row of bdc;

- Place the second insert in the second row of bdc;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- Place the last hit to the top of table control;

- Place the next hit in the second row;

- .... and so

For more info: Search in SDN with TABLE CONTROL IN BDC.

Will get a lot of related links.

Reward points if this Helps.

Manish

Former Member
0 Kudos
392

hi there

This is the code to handle BDC table control for sales

order screen, VA02.

PERFORM bdc_dynpro USING 'SAPMV45A' '0102'.

PERFORM bdc_field USING 'BDC_CURSOR'

'VBAK-VBELN'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'VBAK-VBELN'

i_final-sls_docno.

PERFORM bdc_dynpro USING 'SAPMV45A'

'4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=POPO'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'0251'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV45A-POSNR'.

PERFORM bdc_field USING 'RV45A-POSNR'

i_final-sls_docitm.

PERFORM bdc_field USING 'BDC_OKCODE'

'=POSI'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=PEIN'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'4003'.

LOOP AT i_vbep WHERE vbeln = v1_docno

AND posnr = v1_docitm..

IF i_vbep-wmeng GT 0.

PERFORM bdc_field USING 'BDC_OKCODE'

'=EIPO'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'0252'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV45A-ETDAT'.

CLEAR w_date.

WRITE i_vbep-edatu TO w_date DD/MM/YYYY.

PERFORM bdc_field USING 'RV45A-ETDAT'

w_date.

IF i_final-kitstatus EQ 'KC'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=POSI'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'4003'.

PERFORM bdc_field USING 'VBEP-LIFSP(01)'

c_blank.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'. "Enter

PERFORM bdc_dynpro USING 'SAPMV45A'

'4003'.

PERFORM bdc_field USING 'VBEP-LIFSP(01)'

c_delblk.

ELSE.

PERFORM bdc_field USING 'BDC_OKCODE'

'=POSI'.

PERFORM bdc_dynpro USING 'SAPMV45A'

'4003'.

PERFORM bdc_field USING 'BDC_CURSOR'

'VBEP-LIFSP(01)'.

PERFORM bdc_field USING 'VBEP-LIFSP(01)'

c_delblk.

ENDIF.

ENDIF.

ENDLOOP.

  • Save the document

PERFORM bdc_field USING 'BDC_OKCODE' '=SICH'.

CALL TRANSACTION 'VA02' USING i_bdcdata

MODE v_mode

UPDATE 'S'

MESSAGES INTO

i_bdcmessage.

do reward if helpful.