Hi Sujeet
If your requirement suits, you can use dynamic programming which is a nice feature of ABAP.
You can use field-symbols (think them of as aliases for fields) or generic variables.
For more information I recommend the e-class "Advanced" target="_blank">https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/eclasses/teched04/ABAP351.htm">"Advanced and Generic Programming in ABAP".
As a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts which help you solving your problem. You can reward points by clicking the yellow star icon at header of each post. You can assign:
- one 10 points (solved)
- two 6 points (very helpful answer)
- many 2 points (helpful answer)
Kind regards...
*--Serdar
Why don't you use Field-Symbols, you can use it for any type, not just characters and of any length ?
data: x type char5, y type char10. FIELD-SYMBOLS : <FS> TYPE ANY. assign x to <FS>. write : <FS>. assign y to <FS>. write: <FS>.
Secondly, I don't think it would be possible to cast from a lower length character type to a higher length character type.
You can do casting in <b>ASSIGN</b>.
Regards,
Subramanian V.
Hello Sujeet,
Once you have declared the variable x with the type CHAR5, you cannot change the type of this variable.
However, you have the option of using a field-symbol. You can declare a generic field symbol and assign to it any data object of any length (or type). Consider this example.
field-symbols <fs> type any. data : char1(5) type c value 'SAPAG', char2(8) type c value 'SAPINDIA'. assign char1 to <fs>. write <fs>. assign char2 to <fs>. write <fs>.
Get back if you still have any doubts.
Regards,
Anand Mandalika.
Casting is possible using field-symbols. There are various options around the ASSIGN command. However casting char5 to char10 is problematic, since the original is smaller than the target representation.
Kind Regards
Klaus
Add a comment