‎2006 Jun 26 9:18 AM
Can i avoid the Case .. Endcase in the following code: (like in C i cud have used array and did something like wa[tabix] = wa_in)
DATA: itab TYPE TABLE OF string,
sep(3) VALUE '[*]',
p_head type string.
data: begin of itab_show Occurs 0,
col1(20),
col2(20),
.....
col8(20),
end of itab_show.
p_head = 'Bolier No.[*]1[*]2[*]3[*]4[*]5[*]6[*]TOTAL'.
SPLIT p_head AT sep INTO:
TABLE itab.
loop at itab into wa_in.
case tabix.
when 1.
wa-col1 = wa_in.
when 2.
wa-col2 = wa_in.
....
when 8.
wa-col8 = wa_in.
endloop.
Append wa to itab_show.*... exporting itab_show to smartform interface
‎2006 Jun 26 9:24 AM
Hi,
You can do something like this -
loop at itab assigning <fs_wa>.
l_index = sy-tabix.
assign component l of structure <fs_wa> to <fs_col>.
<fs_col> = wa_in.
endloop.Of course, you need to declare the necessary field symbols...
Regards,
Anand Mandalika.
‎2006 Jun 26 9:23 AM
Hi
You can use a field-symbol to fill ypur array:
FIELD-SYMBOLS: <FS_FIELD> TYPE ANY.
loop at itab into wa_in.
ASSIGN COMPONENT SY-TABIX OF STRUCTURE WA TO <FS_FIELD>.
IF SY-SUBRC = 0.
<FS_FIELD> = WA_IN.
ENDIF.
*case tabix.
*when 1.
*wa-col1 = wa_in.
*when 2.
*wa-col2 = wa_in.
*....
*when 8.
*wa-col8 = wa_in.
endloop.
Max
‎2006 Jun 26 9:24 AM
Hi,
You can do something like this -
loop at itab assigning <fs_wa>.
l_index = sy-tabix.
assign component l of structure <fs_wa> to <fs_col>.
<fs_col> = wa_in.
endloop.Of course, you need to declare the necessary field symbols...
Regards,
Anand Mandalika.
‎2006 Jun 26 9:31 AM
Hi,
Try if this is possible in ur case
p_head = 'Bolier No.[]1[]2[]3[]4[]5[]6[*]TOTAL'.
SPLIT p_head
AT sep
INTO wa-col1 wa-col2 wa-col3 wa-col4 wa-col5 ....Extra_string
‎2006 Jun 26 9:34 AM
Hai Flora
Go through the following Link
This documentation should answer your question. I use field symbols when using dynamic programming.
Just go through these links.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/content.htm
Field-Symbols are place holders for existing fields.
A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
Field-Symbols are like Pointers in Programming language C .
Syntax check is not effective.
Syntax :
Data : v1(4) value abcd.
Field-symbols <fs>.
Assign v1 to <fs>.
Write:/ <fs>.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
Thanks & regards
Sreeni