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: 

How to upload data in to custom control

Former Member
0 Kudos

hello freinds can any one tell me how to upload data into cutom control area using bdc, for example when i record the transaction 'ac02', i am able to enter the long text column but when i generate i am unable to see which field the data is saved , so that i am unable to go further

can any one tell what is the process

bye

afzal

3 REPLIES 3

Former Member
0 Kudos

REPORT demo_custom_control .

  • Declarations

*****************************************************

CLASS event_handler DEFINITION.

PUBLIC SECTION.

METHODS: handle_f1 FOR EVENT f1 OF cl_gui_textedit

IMPORTING sender,

handle_f4 FOR EVENT f4 OF cl_gui_textedit

IMPORTING sender.

ENDCLASS.

DATA: ok_code LIKE sy-ucomm,

save_ok LIKE sy-ucomm.

DATA: init,

container TYPE REF TO cl_gui_custom_container,

editor TYPE REF TO cl_gui_textedit.

DATA: event_tab TYPE cntl_simple_events,

event TYPE cntl_simple_event.

BC - ABAP Programming SAP AG

Custom Controls

672 December 1999

DATA: line(256),

text_tab LIKE STANDARD TABLE OF line,

field LIKE line.

DATA handle TYPE REF TO event_handler.

  • Reporting Events

***************************************************

START-OF-SELECTION.

line = 'First line in TextEditControl'.

APPEND line TO text_tab.

line = '----


'.

APPEND line TO text_tab.

line = '...'.

APPEND line TO text_tab.

CALL SCREEN 100.

  • Dialog Modules

*****************************************************

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

IF init is initial.

init = 'X'.

CREATE OBJECT:

container EXPORTING container_name = 'TEXTEDIT',

editor EXPORTING parent = container,

handle.

event-eventid = cl_gui_textedit=>event_f1.

event-appl_event = ' '. "system event

APPEND event TO event_tab.

event-eventid = cl_gui_textedit=>event_f4.

event-appl_event = 'X'. "application

event

APPEND event TO event_tab.

CALL METHOD: editor->set_registered_events

EXPORTING events = event_tab.

SET HANDLER handle->handle_f1

handle->handle_f4 FOR editor.

ENDIF.

CALL METHOD editor->set_text_as_stream

EXPORTING text = text_tab.

ENDMODULE.

MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'INSERT'.

CALL METHOD editor->get_text_as_stream

IMPORTING text = text_tab.

WHEN 'F1'.

SAP AG BC - ABAP Programming

Custom Controls

December 1999 673

MESSAGE i888(sabapdocu) WITH text-001.

WHEN OTHERS.

MESSAGE i888(sabapdocu) WITH text-002.

CALL METHOD cl_gui_cfw=>dispatch.

ENDCASE.

SET SCREEN 100.

ENDMODULE.

  • Class Implementations

**********************************************

CLASS event_handler IMPLEMENTATION.

METHOD handle_f1.

DATA row TYPE i.

MESSAGE i888(sabapdocu) WITH text-003.

CALL METHOD sender->get_selection_pos

IMPORTING from_line = row.

CALL METHOD sender->get_line_text

EXPORTING line_number = row

IMPORTING text = field.

CALL METHOD cl_gui_cfw=>set_new_ok_code

EXPORTING new_code = 'F1'.

CALL METHOD cl_gui_cfw=>flush.

ENDMETHOD.

METHOD handle_f4.

DATA row TYPE i.

MESSAGE i888(sabapdocu) WITH text-004.

CALL METHOD sender->get_selection_pos

IMPORTING from_line = row.

CALL METHOD sender->get_line_text

EXPORTING line_number = row

IMPORTING text = field.

CALL METHOD cl_gui_cfw=>flush.

ENDMETHOD.

ENDCLASS.

The layout of screen 100 is:

Former Member
0 Kudos

Hi ..

Long text are a little pain in BDC...they are maintained separately in the system...

Where you are filling the long text ..there would be an icon for full screen ...click on tht ...Click Goto-> Header ...

There would be four details on top clubbed together ...note down these...

You have to pass <b>Text ID Text Name Text Object</b> for every text you create tht u create through FM save_text

Below is code written by me for uploading long texts for material but the logic remains the same:

tables : t100.

data: begin of record OCCURS 0,

  • data element: MTART

MTART_001(004),

  • data element: XFELD

KZSEL_01_002(001),

  • data element: XFELD

KZSEL_10_003(001),

  • data element: WERKS_D

WERKS_004(004),

  • data element: LGORT_D

LGORT_005(004),

  • data element: MAKTX

MAKTX_006(040),

  • data element: MEINS

MEINS_007(003),

  • data element: MATKL

MATKL_008(009),

  • data element: BISMT

BISMT_009(018),

  • data element: LABOR

LABOR_010(003),

  • data element: MAKTX

MAKTX_011(040),

  • data element: MEINS

MEINS_012(003),

  • data element: LGPBE

LGPBE_013(010),

  • data element: DATTP

IPRKZ_014(001),

<b>length(1000),</b>

end of record.

*types : begin of str_orig,

  • line(256) type c,

  • end of str_orig.

*data : it_orig type standard table of str_orig with default key,

  • wa_orig type str_orig,

data : text_length TYPE i,

loop_times TYPE i,

char_pos_last TYPE i,

char_pos_curr TYPE i,

no_lines TYPE i.

DATA : VALUE TYPE RMMG1-MATNR.

DATA : NUMBER TYPE RMMG1-MATNR.

data : theader type thead ,

ITAB type standard table of TLINE with default key,

wa type tline.

data itabrec like table of record with header line.

data : bdcdata type standard table of bdcdata with header line.

data : messtab type standard table of bdcmsgcoll with header line.

data mstring(300).

start-of-selection.

<b>theader-tdobject = 'MATERIAL'.

*header-tdname =

theader-tdid = 'GRUN'.

theader-tdform = 'SYSTEM'.

theader-tdspras = 'E'.</b>

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = ''

FILETYPE = 'DAT'

TABLES

DATA_TAB = itabrec.

*perform open_dataset using dataset.

*perform open_group.

loop at itabrec.

refresh bdcdata.

refresh messtab.

perform map_data.

call transaction 'MM01' using bdcdata mode 'N' update 'S' messages into messtab.

<b>text_length = strlen( itabrec-length ).

char_pos_curr = 0.

char_pos_last = 0.

loop_times = text_length DIV 72.

loop_times = loop_times + 1.

DO loop_times TIMES.

char_pos_curr = char_pos_curr + 72.</b> wa-tdline =

itabrec-length+char_pos_last(72).

wa-tdformat = '* '.

APPEND wa to itab.

clear wa.

char_pos_last = char_pos_curr - 1.

enddo.

wa-tdformat = ''.

*wa-tdline = ITABREC-LENGTH.

*append wa to itab.

*

<b>

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = SY-MSGV1

IMPORTING

OUTPUT = NUMBER .

THEADER-TDNAME = NUMBER.</b>

<b>CALL FUNCTION 'SAVE_TEXT'</b> EXPORTING

CLIENT = SY-MANDT

HEADER = THEADER

INSERT = 'X'

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = itab

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • OBJECT = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

clear itab.

perform get_messages.

endloop.

      • End generated data section ***

*start-of-selection.

*perform open_dataset using dataset.

*do.

*read dataset dataset into record.

*if sy-subrc <> 0. exit. endif.

form map_data.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-MTART'

itabrec-MTART_001.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(10)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

itabrec-KZSEL_01_002.

perform bdc_field using 'MSICHTAUSW-KZSEL(10)'

itabrec-KZSEL_10_003.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-LGORT'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

itabrec-WERKS_004.

perform bdc_field using 'RMMG1-LGORT'

itabrec-LGORT_005.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

itabrec-MAKTX_006.

perform bdc_field using 'BDC_CURSOR'

'MARA-LABOR'.

perform bdc_field using 'MARA-MEINS'

itabrec-MEINS_007.

perform bdc_field using 'MARA-MATKL'

itabrec-MATKL_008.

perform bdc_field using 'MARA-BISMT'

itabrec-BISMT_009.

perform bdc_field using 'MARA-LABOR'

itabrec-LABOR_010.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MAKT-MAKTX'

itabrec-MAKTX_011.

perform bdc_field using 'BDC_CURSOR'

'MARD-LGPBE'.

perform bdc_field using 'MARA-MEINS'

itabrec-MEINS_012.

perform bdc_field using 'MARD-LGPBE'

itabrec-LGPBE_013.

perform bdc_field using 'MARA-IPRKZ'

itabrec-IPRKZ_014.

endform.

form get_messages.

loop at messtab.

select single * from t100 where sprsl = messtab-msgspra and

arbgb = messtab-msgid and

msgnr = messtab-msgnr.

if sy-subrc = 0.

mstring = t100-text.

if mstring CS '&'.

replace '&' with messtab-msgv1 into mstring.

replace '&' with messtab-msgv2 into mstring.

replace '&' with messtab-msgv3 into mstring.

replace '&' with messtab-msgv4 into mstring.

endif.

condense mstring.

write 😕 mstring(300) color 2 intensified off.

else.

write : messtab.

endif.

endloop.

endform.

form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform.

form bdc_field using fnam fval.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata.

endform.

ANy other help u need, lemme know!!

Message was edited by:

shweta soni

Former Member
0 Kudos

For the text name your job is easy as it is the same as the number of the service you are trying to change in ac02...

your art lies in supplying the header details in the save_text..study tht well for running ur bdc successfully

lemme know if u get stuck anywhere!!