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

Dynamic customer table maintenance

Former Member
0 Likes
637

I am working on dynamic development of cusomter tables mainenance. The program provides selection screen dynamically based on the key fields of each table and generates ALV list with table contents. When user double click on any of row, I would like to open up non-key fields in edit mode for editing. Somehow I am stuck when I tried to update work area of internal table with deep structure - handle style - lvc_s_styl. Can anybody help me on it?

any ideas?

your help will be very appreciated.

thanks,

Kelly

FIELD-SYMBOLS: <tab> TYPE standard TABLE,

<wa_tab> type any,

<ls_edit> type lvc_s_styl,

<col> TYPE ANY.

ls_edit-fieldname = e_column-fieldname.

ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.

ls_edit-style2 = space.

ls_edit-style3 = space.

ls_edit-style4 = space.

ls_edit-maxlen = 8.

INSERT ls_edit INTO TABLE lt_edit.

LOOP AT <tab> ASSIGNING <wa_tab>.

IF e_row = sy-tabix .

ASSIGN COMPONENT l_colname OF STRUCTURE <wa_tab> TO <col>.

ASSIGN ls_edit TO <col>.

I want to update <wa_tab>-handle_style with <col>, how do I do it? <Col> contains the same structure with deep structure handle_style.

MANDT 400

WERKS 0002

MATNR 000000000000040066

VERID 0110

SEQUENCE 010

PPRESRC

PAN_SIZE 0000

DOCUMENT
Toriis02\Inetpub\MasterProAndPKGDoc\sappdf\ALL-BPO-300CA.pdf

DIVIDER 0000

HANDLE_STYPE Structure: flat & not charlike

FIELDNAME

STYLE 00000000

STYLE2 00000000

STYLE3 00000000

STYLE4 00000000

MAXLEN 0

MODIFY <tab> FROM <wa_tab>.

endloop.

Edited by: Kelly Gao on Mar 13, 2009 7:22 PM

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
567

Hello Kelly

In my Wiki posting

[Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI]

I have described in detail how to build and fill complex itabs dynamically.

Regards

Uwe

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
568

Hello Kelly

In my Wiki posting

[Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI]

I have described in detail how to build and fill complex itabs dynamically.

Regards

Uwe

Read only

MarcinPciak
Active Contributor
0 Likes
567

Hi Kelly,

I guess <wa_tab>-handle_style is of type lvc_t_styl therefore you can do the following:


ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.

"I assume you know your non-key fields' names so you can use subrotuine to perform update on each of them
ls_edit-fieldname =  'First field name' .
PERFORM update ls_edit.
ls_edit-fieldname =  'Second field name'.
PERFORM update ls_edit.
ls_edit-fieldname = 'Third field name'.
PERFORM update ls_edit 


FORM update USING fs_edit type lvc_s_styl.

field-symbols: <style_tab> type lvc_t_styl,
                     <style_wa> type lvc_s_styl.

LOOP AT <tab> ASSIGNING <wa_tab>.
   if e_row = sy-tabix .
     "get you style table
     assign component 'HANDLE_STYLE' of structure <wa_tab> to <style_tab>.

     "as <style_tab> is typed fully you can read the row you are interested in
     read table <style_tab> assigning <style_wa> with key fieldname = fs_edit-fieldname
     if sy-subrc = 0.
       "update this entry
        <style_wa> = fs_edit.
*        modify table <style_tab> from <style_wa>.  
     endif.
   endif.
endloop.

endform.

Note!

Though, this should work, the use of RTTI as Uwe suggested would be best practise approach as far as dynamic programming is concerned. Anyhow it is still up to you which one you pick.

Regards

Marcin

I noticed now that this line is not necessary


 modify table <style_tab> from <style_wa>.  

as we simply are working with field symbols, so changes made to <style_wa> are already visible in that table <style_tab>.

Edited by: Marcin Pciak on Mar 15, 2009 12:44 PM

Read only

Former Member
0 Likes
567

Thanks for Uwe and Marcin's input. It worked now. I can continue working on my program.

Many thanks,