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: 

table control program

0 Kudos

Hii all,

Can anyone send me a sample program on table control? I have one requirement where i need to populate some fields in table control along with checkboxes. please send me a program so that i can understand and go ahead with my development.

thanks to all,

shakir

4 REPLIES 4

shishupalreddy
Active Contributor
0 Kudos

hi,

go through this code .

FORM bdc_create_session .

PERFORM bdc_populate_data_mb1b.

IF g_f_lines IS INITIAL.

EXIT.

ELSE.

PERFORM bdc_open_group.

PERFORM bdc_populate_data_lt06.

PERFORM bdc_close_group.

ENDIF.

ENDFORM. " bdc_create_session

&----


*& Form bdc_open_group

&----


  • BDC Open Group

----


FORM bdc_open_group .

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = p_bdc_tx

keep = 'X'

user = sy-uname

EXCEPTIONS

client_invalid = 1

destination_invalid = 2

group_invalid = 3

group_is_locked = 4

holddate_invalid = 5

internal_error = 6

queue_error = 7

running = 8

system_lock_error = 9

user_invalid = 10

OTHERS = 11.

CASE sy-subrc.

WHEN 0.

WHEN OTHERS.

WRITE: / 'BDC OPEN ERROR', sy-subrc.

ENDCASE.

ENDFORM. " bdc_open_group

&----


*& Form bdc_populate_data_mb1b

&----


  • BDCDATA Population For MB1B

----


FORM bdc_populate_data_mb1b .

DATA:w_meins LIKE mara-meins,

w_erfmg(17).

LOOP AT g_t_itab.

REFRESH bdcdata.

REFRESH t_msg.

*&Screen 400

PERFORM bdc_dynpro USING 'SAPMM07M'

'0400'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM07M-BWARTWA'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'MKPF-BKTXT'

g_f_text. " '93900GOLIVE 9062 TO 9064'. "

PERFORM bdc_field USING 'RM07M-BWARTWA'

g_f_mvttype. "'301'. "

PERFORM bdc_field USING 'RM07M-WERKS'

g_t_itab-werks.

PERFORM bdc_field USING 'RM07M-LGORT'

g_t_itab-lgort.

*&Screen 421

PERFORM bdc_dynpro USING 'SAPMM07M'

'0421'.

PERFORM bdc_field USING 'BDC_CURSOR'

'MSEG-CHARG(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'MSEGK-UMWRK'

p_dwerks.

PERFORM bdc_field USING 'MSEGK-UMLGO'

p_dlgort.

PERFORM bdc_field USING 'MSEG-MATNR(01)' g_t_itab-matnr .

w_erfmg = g_t_itab-erfmg.

PERFORM bdc_field USING 'MSEG-ERFMG(01)' w_erfmg .

CLEAR w_meins.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = g_t_itab-matnr

IMPORTING

output = g_t_itab-matnr.

SELECT SINGLE meins

INTO w_meins

FROM mara

WHERE matnr = g_t_itab-matnr.

PERFORM bdc_field USING 'MSEG-ERFME(01)' w_meins .

  • LOOP AT g_t_matnr.

  • PERFORM bdc_detail.

*

  • endloop.

PERFORM bdc_field USING 'DKACB-FMORE' 'X'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

  • PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=ENTE'.

*

  • PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=ENTE'.

PERFORM bdc_dynpro USING 'SAPMM07M'

'0421'.

PERFORM bdc_field USING 'BDC_CURSOR'

'MSEG-ERFMG(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

w_tcode = 'MB1B'.

PERFORM call_transaction.

ENDLOOP.

ENDFORM. " bdc_populate_data_mb1b

*ENDFORM. " BDC_FIELD_IDX

&----


*& Form bdc_populate_data_lt06

&----


  • BDCDATA population For LT06

----


FORM bdc_populate_data_lt06 .

DATA: date1 LIKE sy-datum,

w_year(04).

date1 = sy-datum.

LOOP AT g_t_mblnr.

REFRESH bdcdata.

PERFORM bdc_dynpro USING 'SAPML02B'

'0203'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RL02B-DUNKL'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RL02B-MBLNR'

g_t_mblnr-mblnr.

WRITE sy-datum TO w_date DD/MM/YYYY.

MOVE w_date+6(4) TO w_date1.

PERFORM bdc_field USING 'RL02B-MJAHR'

w_date1.

PERFORM bdc_field USING 'RL02B-LGNUM'

p_lgnum.

PERFORM bdc_field USING 'RL02B-DUNKL'

'D'.

w_tcode = 'LT06'.

PERFORM bdc_insert USING w_tcode.

ENDLOOP.

ENDFORM. " bdc_populate_data_lt06

&----


*& Form bdc_insert

&----


  • BDC Insert

----


FORM bdc_insert USING p_w_tcode.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = p_w_tcode

TABLES

dynprotab = bdcdata

EXCEPTIONS

internal_error = 1

not_open = 2

queue_error = 3

tcode_invalid = 4

printing_invalid = 5

posting_invalid = 6

OTHERS = 7.

CASE sy-subrc.

WHEN 0.

WHEN OTHERS.

WRITE: / 'BDC INSERT ERROR', sy-subrc.

ENDCASE.

ENDFORM. " bdc_insert

&----


*& Form bdc_close_group

&----


  • BDC Close Group

----


FORM bdc_close_group .

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 1

queue_error = 2

OTHERS = 3.

CASE sy-subrc.

WHEN 0.

WHEN OTHERS.

WRITE: / 'BDC CLOSE ERROR', sy-subrc.

ENDCASE.

ENDFORM. " bdc_close_group

----


  • Start new screen *

----


FORM bdc_dynpro USING program dynpro LIKE bdcdata-dynpro.

CLEAR bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

APPEND bdcdata.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM bdc_field USING fnam fval .

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

ENDFORM. "BDC_FIELD

&----


*& Form call_transaction

&----


  • Call Transaction For MB1B For Material Document Generation

----


FORM call_transaction .

DATA: w_mode VALUE 'N'.

DATA:w_errors TYPE i.

DATA:l_matnr LIKE mseg-matnr.

  • Exucute transaction via Call Transaction

CALL TRANSACTION 'MB1B'

USING bdcdata

MODE w_mode

UPDATE 'S'

MESSAGES INTO t_msg .

  • check for all terminal error messages

READ TABLE t_msg WITH KEY msgtyp = 'S'

msgid = 'M7'

msgnr = '060'.

IF sy-subrc EQ 0.

  • g_t_mblnr-status = 'G'.

g_t_mblnr-mblnr = t_msg-msgv1.

  • Including Material Document in the upload table

APPEND g_t_mblnr.

ADD 1 TO g_f_lines.

ELSE.

LOOP AT t_msg.

  • IF t_msg-msgtyp = 'E'.

ADD 1 TO w_errors.

l_arbgb = t_msg-msgid.

l_msgnr = t_msg-msgnr.

l_matnr = g_t_itab-matnr.

*t_msg-msgv2.

CALL FUNCTION 'RP_READ_T100'

EXPORTING

arbgb = l_arbgb

msgnr = l_msgnr

  • MSGV1 = ' '

  • MSGV2 = ' '

  • MSGV3 = ' '

  • MSGV4 = ' '

  • SPRSL = SY-LANGU

IMPORTING

text = l_text

EXCEPTIONS

no_entry_found = 1

OTHERS = 2

.

t_itab-status = l_text.

t_itab-matnr = l_matnr.

APPEND t_itab TO g_t_err_log.

  • ENDIF.

ENDLOOP.

endif.

ENDFORM. " call_transaction

regards,

gopi_narendra
Active Contributor
0 Kudos

Hi go thru the sample programs

demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

and tcode DWDM

Regards

- Gopi

Former Member
0 Kudos

Hi Shakir,

Why don't you use Table Control Wizard from the screen

itself.

Its very simple. Step by step and It will generate

Code for you.

Reward points if this helps.

Manish

former_member181962
Active Contributor
0 Kudos

Refer the standard programs:

DEMO_DYNPRO_TABLE_CONTROL_1

DEMO_DYNPRO_TABLE_CONTROL_2

RSDEMO_TABLE_CONTROL

Also see:

RSDEMO02 (Its very good)

Regards,

ravi

Message was edited by: Ravi Kanth Talagana