‎2007 Feb 21 3:40 PM
I realize there is a Dictionary forum but I felt it fit in best here.
Below is code that I am trying to implement. I'm stuck on this report because I can't grasp the best way to organize the needed data.
data: begin of itab occurs 0,
mblnr type mkpf-mblnr, "Mat. Doc. Number
mjahr type mkpf-mjahr, "Mat. Doc. Year
bwart type mseg-bwart, "Movement Type
matnr type mseg-matnr, "Mat. #
werks type mseg-werks, "Plant #
maktl type mara-matkl, "Mat Group
mtart type mara-mtart, "Mat Type
maktx type makt-maktx, "Mat Description
days type z45days,
end of itab.Basically what I need is a table of type itab. Each 'row' will include what you see above and <b>days</b> is nothing more than 45 fields of type Unit. I'm not sure how to go about creating a table of this line type. The table will be huge, with at least 10K lines (each being of type itab). So this question as two parts,
1: How do I get this to create a table like I need?
2: Is there a better way to do this?
Regards,
Davis
‎2007 Feb 21 3:47 PM
Why not do something like:-
TYPES: BEGIN OF ty_itab,
mblnr TYPE mkpf-mblnr, "Mat. Doc. Number
mjahr TYPE mkpf-mjahr, "Mat. Doc. Year
bwart TYPE mseg-bwart, "Movement Type
matnr TYPE mseg-matnr, "Mat. #
werks TYPE mseg-werks, "Plant #
maktl TYPE mara-matkl, "Mat Group
mtart TYPE mara-mtart, "Mat Type
maktx TYPE makt-maktx, "Mat Description
days TYPE z45days,
END OF ty_itab.
DATA: st_itab TYPE ty_itab.
DATA: t_itab TYPE TABLE OF ty_itab.It is better to use a separate work area and internal table. Other than that I see no problems with your code.
Gareth.
‎2007 Feb 21 3:43 PM
Hi Davis,
could you be more clear with the question.
regards,
madhu
‎2007 Feb 21 3:49 PM
My question is how do I turn this into a table. How do I go from this single structure (itab) to a table of this structure? Do I do something like this:
DATA: it_table type itab.
That doesn't look right to me. I'm used to the .NET languages so this is completely different for me. I would assume that it would be best to do this using pointers and a table of pointers but I'm not sure; I know that would be the best way if I was doing it in C++, C#, etc...
Regards,
Davis
‎2007 Feb 21 3:52 PM
Your code had already declared it as a table. By adding the "Occurs 0" onto the end you are setting it to be as a table so your code was fine
But in saying that, as I said in my other reply it is much better to define a type to declare the structure of your table, then declare a structure field to act as the header line and then declare the table itself, all based on the same type.
You can then process the table with
Loop at itab into st_itab.etc.
Gareth.
‎2007 Feb 21 3:44 PM
Hi!
This is called as an include structure. It seems OK for me.
You will address the fields in your internal table somehow like this: itab-days-day1.
Regards
Tamá
‎2007 Feb 21 3:47 PM
Why not do something like:-
TYPES: BEGIN OF ty_itab,
mblnr TYPE mkpf-mblnr, "Mat. Doc. Number
mjahr TYPE mkpf-mjahr, "Mat. Doc. Year
bwart TYPE mseg-bwart, "Movement Type
matnr TYPE mseg-matnr, "Mat. #
werks TYPE mseg-werks, "Plant #
maktl TYPE mara-matkl, "Mat Group
mtart TYPE mara-mtart, "Mat Type
maktx TYPE makt-maktx, "Mat Description
days TYPE z45days,
END OF ty_itab.
DATA: st_itab TYPE ty_itab.
DATA: t_itab TYPE TABLE OF ty_itab.It is better to use a separate work area and internal table. Other than that I see no problems with your code.
Gareth.
‎2007 Feb 21 3:53 PM
Gereth, thanks. This is what I was after. I haven't had any training courses yet where they showed this. How do I add a line to the table? I work in the work area then append that work area to the table? Sorry for all of the trivial questions!
Regards,
Aaron
EDIT: In the following what is st_tab? I realize t_itab is an internal table so I guess st_itab is the work area?
Message was edited by:
Davis
‎2007 Feb 21 3:58 PM
Hi,
Thats exactly what you do. You use the work area (ST_ITAB - st is just short for structure - call it what yuo want!) to change a row and then you can use something like
APPEND st_itab to t_itab.or
MODIFY TABLE t_itab from st_itab.For info, if you put your cursor on these words and press F1 the SAP help is quite good for internal tables.
Gareth.
‎2007 Feb 21 4:05 PM
Gareth, thanks a lot for all of your help! I can't wait until I am proficient enough in this language to help people out. The language doesn't seem too hard, it's just hard transitioning from one mindset to another, and this transition is worse than any I've ever had to make. Thanks again!
Regards,
Davis.
‎2007 Feb 21 4:07 PM
Gareth, thanks a lot for all of your help! I can't wait until I am proficiant enough in this language to help people out. The language doesn't seem too hard, it's just hard transitioning from one mindset to another, and this transition is worse than any I've ever had to make. Thanks again!
Regards,
Davis.
‎2007 Feb 22 9:56 AM
Hi,
No problem! I went through a similar thing recently learning Java - its all good fun!
Gareth.