Application Development and Automation 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: 
Read only

any function module available

Former Member
0 Likes
569

Hi to all

Any function module is available to handle views in material master application while data transfer.

Also tell me how to describe the handling of table control in BDC.for interview purpose.

Thanks

Anubhav

6 REPLIES 6
Read only

Former Member
0 Likes
546

Any function module is available to handle views in material master application while data transfer.

SELECTION_VIEWS_FIND

BDC Table control logic :

report zpochange.

data : i_error like bdcmsgcoll occurs 0 with header line.

data : i_bdcdata like bdcdata occurs 0 with header line.

tables : ekko, ekpo.

data :c1(10) value 'ME22',

c2(1) value ',',c3(10).

data : var1(20). " LIKE EKKO-EBELN.

data : var2 like ekko-ebeln.

data : begin of i_ekko occurs 0,

header(2),

ebeln like ekko-ebeln,

end of i_ekko.

data : begin of i_ekpo occurs 0,

item(2),

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

menge(10), " LIKE EKPO-MENGE,

end of i_ekpo.

data : v like ekpo-ebelp.

data: begin of itab occurs 0,

text(300),

end of itab.

parameters: p_file like ibipparms-path.

*PARAMETERS: PONUMBER LIKE EKPO-EBELN.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

importing

file_name = p_file

.

start-of-selection.

*SELECT EBELN FROM EKKO INTO TABLE I_EKKO WHERE EBELN = PONUMBER.

*

  • SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE I_EKPO WHERE EBELN

*= PONUMBER.

*

perform get_data.

*LOOP AT ITAB.

  • WRITE 😕 ITAB.

  • ENDLOOP.

loop at itab.

var1 = itab-text+0(1).

if var1 = 'H'.

*I_EKKO-EBELN = ITAB-TEXT.

split itab at c2 into i_ekko-header

i_ekko-ebeln.

  • SPLIT ITAB AT ',' INTO I_EKKO-EBELN.

    • " I_EKPO-EBELP

    • " I_EKPO-MENGE

    • " var1.

append i_ekko.

else.

split itab at c2 into i_ekpo-item

i_ekpo-ebeln

i_ekpo-ebelp

i_ekpo-menge.

append i_ekpo.

endif.

*var2 = i_ekpo-ebeln.

  • MOVE VAR1 TO I_EKPO-EBELN.

  • MOVE VAR1 TO I_EKKO-EBELN.

  • APPEND: I_EKPO.

*if not var1 is initial.

  • split var1 at ',' into i_ekpo-ebelp

  • i_ekpo-menge.

  • i_ekpo-ebeln = var2.

  • append i_ekpo.

*endif.

endloop.

loop at i_ekpo.

write 😕 i_ekpo.

endloop.

*

loop at i_ekko.

perform fill_data. " TABLES I_EKPO.

endloop.

  • LOOP AT I_EKPO.

  • WRITE 😕 I_EKPO.

  • ENDLOOP.

*&----


*& Form GET_DATA

*&----


  • text

*----


  • --> p1 text

  • <-- p2 text

*----


*LOOP AT I_ERROR.

  • WRITE 😕 I_ERROR.

  • ENDLOOP.

*

form get_data.

call function 'WS_UPLOAD'

exporting

codepage = ' '

filename = p_file

filetype = 'ASC'

headlen = ' '

line_exit = ' '

trunclen = ' '

user_form = ' '

user_prog = ' '

dat_d_format = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = itab

exceptions

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

others = 10

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " GET_DATA

*&----


*& Form FILL_DATA

*&----


  • text

*----


  • -->P_I_EKPO text

*----


form fill_data. " tables i_ekpo .

perform bdcscreen using 'SAPMM06E' '0105'.

perform bdcfield using 'RM06E-BSTNR' i_ekko-ebeln.

perform bdcfield using 'BDC_OKCODE' '/00'.

loop at i_ekpo where ebeln = i_ekko-ebeln.

  • V = I_EKPO-EBELP.

perform bdcscreen using 'SAPMM06E' 0120.

perform bdcfield using 'BDC_CURSOR' 'RM06E-EBELP'.

perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.

perform bdcfield using 'BDC_OKCODE' '/00'.

perform bdcscreen using 'SAPMM06E' 0120.

perform bdcfield using 'BDC_CURSOR' 'EKPO-MENGE(01)'.

perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.

perform bdcfield using 'EKPO-MENGE(01)' i_ekpo-menge.

perform bdcfield using 'BDC_OKCODE' '/00'.

*PERFORM BDCSCREEN USING 'SAPMM06E' 0120.

*

*PERFORM BDCFIELD USING 'BDC_CURSOR' 'RMO6E-EBELP'.

*

*CLEAR V.

endloop.

perform bdcfield using 'BDC_OKCODE' '=BU'.

call transaction c1 using i_bdcdata mode 'A'

messages into i_error.

refresh i_bdcdata.

endform. " FILL_DATA

*&----


*& Form BDCSCREEN

*&----


  • text

*----


  • -->P_0140 text

  • -->P_0120 text

*----


form bdcscreen using p_program p_screen.

i_bdcdata-program = p_program.

i_bdcdata-dynpro = p_screen.

i_bdcdata-dynbegin = 'X'.

append i_bdcdata.

clear i_bdcdata.

endform. " BDCSCREEN

*&----


*& Form BDCFIELD

*&----


  • text

*----


  • -->P_0145 text

  • -->P_I_EKPO_EBELN text

*----


form bdcfield using fnam fval.

i_bdcdata-fnam = fnam.

i_bdcdata-fval = fval.

append i_bdcdata.

clear i_bdcdata.

endform. " BDCFIELD

Read only

0 Likes
546

Hi seshu ,

thanks for your solution.

Plz tell me in words , how to handle table control so that i can explain to interviewer.

Read only

0 Likes
546

table control - when you see sales order transaction - it will have multiple line items ( Material # ,item number,qty)

if you did recording it will show vbap-matnr(01) vbap-posnr(01),vbap-kwmeng(01) - this is first item

same thing second or third or and so on

vbap-matnr(02) vbap-posnr(01),vbap-kwmeng(02) - 2nd item

vbap-matnr(03) vbap-posnr(01),vbap-kwmeng(03) 3rd item

vbap-matnr(NN) vbap-posnr(01),vbap-kwmeng(NN) - and so on

you will have file like one header and mutliple items

loop at i_data.

<b> g_ctr = g_ctr + 01. " Counter value

CONCATENATE vbap-matnr '( ' g_ctr ' ) ' INTO g_mabnr.

you use g_mabnr in bdcdata field</b>

endloop.

Read only

0 Likes
546

Thanks for your solution.

Also tell me the concept behind handling views in material master application for BDC transfer.

Thanks & regarda

anubhav

Read only

0 Likes
546

Use this FM - SELECTION_VIEWS_FIND to handle material master views

Read only

Former Member
0 Likes
546

hi,

for handlling table control:

Check this example:

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