2005 Dec 01 12:21 PM
Hi my friends,
just a simple question for you expert ABAPers...
I have to pass info from an internal table (tb_sip) in which every line contains only one char field(250) to another internal table (tb_detsip) with specific fields (chars and numbers).
I'm trying to use this code:
LOOP AT tb_sip.
SPLIT tb_sip AT ";" INTO tb_detsip-field1,
tb_detsip-field2,
(...).
APPEND tb_detsip.
ENDLOOP.
Clearly this is not correct (and clearly I'm not an ABAPer) !
Could you please provide some sample code ready-to-use ?
Thanks in advance to everyone!
Bye,
Roberto
2005 Dec 01 12:32 PM
Hi,
try that:
DATA: BEGIN OF SPTAB OCCURS 0,
line(1000), " or type string
END OF SPTAB.
DATA: IDX LIKE SY-INDEX.
field-symbols <FS1>.
split tb_sip AT ';' INTO table sptab.
LOOP AT SPTAB.
IDX = IDX + 1.
ASSIGN COMPONENT IDX OF STRUCTURE tb_detsip TO <FS1>.
If sy-subrc = 0.
<FS1> = SPTAB-line.
Endif.
Endloop.
append tb_detsip.
clear idx.
Regards Andreas
Hi my friends,
just a simple question for you expert ABAPers...
I have to pass info from an internal table (tb_sip) in which every line contains only one char field(250) to another internal table (tb_detsip) with specific fields (chars and numbers).
I'm trying to use this code:
LOOP AT tb_sip.
SPLIT tb_sip AT ";" INTO tb_detsip-field1,
tb_detsip-field2,
(...).
APPEND tb_detsip.
ENDLOOP.
Clearly this is not correct (and clearly I'm not an ABAPer) !
Could you please provide some sample code ready-to-use ?
Thanks in advance to everyone!
Bye,
Roberto
2005 Dec 01 12:27 PM
Hi,
Use offset if charater position if fixed all time.
and then use MOVE-CORRESPONING Statement.
Regards,
Amey
2005 Dec 01 12:29 PM
Are u getting any wrong results...
but what ever you did is correct..
can you give some sample data..
regards
vijay
2005 Dec 01 12:29 PM
Try to pass the name of your field in the iternal table
loop at tb_sip
SPLIT tb_sip-line AT ';' INTO tg_entrada-tipo
tb_detsip-field1
tb_detsip-field2.
APPEND tg_detsip .
endloop.
Alexandre Nogueira
2005 Dec 01 12:39 PM
Hi guys,
I cannot use offset since the char position is not always the same.
I'm not sure about the correct sintax...
I tried to as Alex suggested (use the field of the internal table to split), but it doesn't work...
"INTO expected after ENDLOOP." is the error message...
Do I have to use comma in the list of target fields ?
Do I have to use colon before this list ?
my separator have to be between "" or '' (as in Alex's example)?
Andreas, could you please provide me also the data declaration part in order to use your sample code?
2005 Dec 01 12:32 PM
Hi,
try that:
DATA: BEGIN OF SPTAB OCCURS 0,
line(1000), " or type string
END OF SPTAB.
DATA: IDX LIKE SY-INDEX.
field-symbols <FS1>.
split tb_sip AT ';' INTO table sptab.
LOOP AT SPTAB.
IDX = IDX + 1.
ASSIGN COMPONENT IDX OF STRUCTURE tb_detsip TO <FS1>.
If sy-subrc = 0.
<FS1> = SPTAB-line.
Endif.
Endloop.
append tb_detsip.
clear idx.
Regards Andreas
2005 Dec 01 12:51 PM
Hi Roberto,
1 one way using split and field symbols.
2. just try this code (copy and paste)
and see the value of table MYITAB.
DATA : str(256) TYPE c.
DATA : BEGIN OF myitab OCCURS 0,
matnr LIKE mara-matnr,
pernr LIKE p0001-pernr,
bukrs LIKE t001-bukrs,
END OF myitab.
DATA : BEGIN OF mysplit OCCURS 0,
myfield(10) TYPE c,
END OF mysplit.
FIELD-SYMBOLS : <w> TYPE ANY.
*----
str = 'abc;00056;ghi'.
SPLIT str AT ';' INTO TABLE mysplit.
*----
LOOP AT mysplit.
ASSIGN COMPONENT sy-tabix OF STRUCTURE myitab TO <w>.
IF sy-subrc = 0.
<w> = mysplit.
ENDIF.
ENDLOOP.
break-point.
Hope it helps.
Regards,
Amit M.
2005 Dec 01 3:46 PM
Just with some correction, but here is the right code (Andreas'suggestion) !
LOOP AT tb_sip.
SPLIT tb_sip-all AT ';' INTO TABLE tb_split.
LOOP AT tb_split.
idx = idx + 1.
ASSIGN COMPONENT idx OF STRUCTURE tb_detsip TO <fs1>.
IF sy-subrc = 0.
<fs1> = tb_split-line.
ENDIF.
ENDLOOP.
APPEND tb_detsip.
CLEAR idx.
ENDLOOP.
Thanks to all !!!
Bye,
Roberto
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |