mig28mx
11th July 2013, 02:07
Hi,
I need to print an array to a report layout.
Lets say:

extern domain total.mes(12,12)


and then fill the array with values:
lets say:

total.mes(1,1) = 1
total.mes(1,2) = 1.1
total.mes (2,1) = 3
....
total.mes(12,12) = 30.5


My problem is that, I need to print all these values on a report.
My first approach was to declare the depth of the array in session ttadv3132s000, but there is only one dimension or subscript.

If I define the field on sesion ttadv3134s000 as total.mes(1,1) when I compile it throws the error:

Error: Illegal number of subscripts for total.mes (while expanding macro 'r_append_line')

Any ideas?

Thank you in advance.

bhushanchanda
11th July 2013, 08:05
Hi,

Declare a variable in Program Script:-

extern domain tcmcs.double arr_test (10,10)


Assign Values:-


arr_test (1,1) = 2.5
arr_test (1,2) = 3.5
arr_test (1,3) = 4.5

On report layout:-

Input Field = arr_test
Depth = 2
Domain = tcmcs.double


In session ttadv3132s000:-

Pass fields like:-

arr_test(1) | This will give you 2.5
arr_test(2) | This will give you 3.5

Hope this works for you.

vamsi_gujjula
11th July 2013, 11:09
hello Mig28mx,

why dont you declare that array(12,12) in report script and work it out...
in that way it would be available(declared) for report.

mig can try launching a missile on that locked target :P ;)

vamsi_gujjula
11th July 2013, 12:48
Hi Mig ,
i tried the my suggestion ... it did not work,
i think..... you should have 12 variables of array length 12 and define then in input fields
or
what ever you calculating should be done in report script(having array 12 X 12) before printing that layout having the array values.

mig28mx
11th July 2013, 21:49
Hi bhushanchanda,
I tried you suggestion but it is not working.
When I put, a fixed value on the screen field, it only take 1 value of the array. The others are not sowing.

Hi vamsi,
Well, my missile on this issue, will be to transform a 12x12 array into a 144 array.

But as far as I know, you only specify a 99 elements in depth, right?

Any other ideas?

Miguel.

bhushanchanda
11th July 2013, 22:02
Yes,

My solution was to print the 12 values on the report as you wanted it to be I guess. What is your exact requirement? What kind of layout are you trying to print? Do, you want to report to pull out the array values on the layout or something else? Please specify.

mig28mx
11th July 2013, 23:04
Hi bhushanchanda,
Thank you for you reply.

Let´s say I have the following:

extern domain tfgld.amnt total.mes(3,3)


And then filled like this:

total.mes(1,1) = 1
total.mes(1,2) = 2
total.mes(1,3) = 3
total.mes(2,1) = 4
total.mes(2,2) = 5
total.mes(2,3) = 6
total.mes(3,1) = 7
total.mes(3,2) = 8
total.mes(3,3) = 9


My requirement is to have a report that shows the following:

Enero Febrero Marzo
Vendor1 total.mes(1,1) total.mes(1,2) total.mes(1,3)
Vendor2 total.mes(2,1) total.mes(2,2) total.mes(2,3)
Vendor3 total.mes(3,1) total.mes(3,2) total.mes(3,3)

What do you think?

Miguel

bhushanchanda
12th July 2013, 07:58
Ok,

You can use 12 variables for that, i.e. for every month 1 variable.

Say a,b,c,d.....

extern domain tcmcs.double total.mes(12,12),a,b,c,d,e,f,g,h,i,j,k,l
long m

Now, collect the values in the array:-

total.mes(1,1) = 1
total.mes(1,2) = 2
total.mes(1,3) = 3
total.mes(2,1) = 4
total.mes(2,2) = 5
total.mes(2,3) = 6
total.mes(3,1) = 7
total.mes(3,2) = 8
total.mes(3,3) = 9
.........

Now, you can use a while or a for loop to assign the values to variables and print them on report

while m <= 12
a = total.mess(m,1)
b = total.mess(m,2)
c = total.mess(m,3)
........
rprt_send()
m = m+1
endwhile

Now, you can just put these variables on the report layout.


Sample:--

i = 1
on.change.check(whinr110.item)
db.set.to.default(twhinr110)
select whinr110.*
from whinr110
where whinr110.trdt inrange {:date.f} and {:date.t}
order by whinr110.item
selectdo
if (changed(whinr110.item) and i <=12) then
arr_test(i,1) = test1
arr_test(i,2) = test2
i = i + 1
endif
test1 = test1 + whinr110.qstk
test2 = test2 + whinr110.qhnd
endselect

i = 1
while i <= 12
a = arr_test(i,1)
b = arr_test(i,2)
i = i + 1
rprt_send()
endwhile

vamsi_gujjula
12th July 2013, 12:03
Hello Mig,

two was as i said are...
1) trans form this total.mes(12,12) into
total.mes.1(12) ,total.mes.2(12), total.mes.3(12), ..... total.mes.12(12)
so the dept of any array is 12 so ican be directly handled in report input variables

2) in report script.......
required.layout:
before.layout:
long total.mes(12,12) | just declaring
use your logic to place the values in the array
say total.mes(12,2) = 122


then in report layout: (black screen)
in print statement (of form field) used 'total.mes(12,2) '

mig28mx
28th February 2014, 03:55
Hi Vamsi,
I forced to print the array value, one by one on my layout.
It is not an elegant solution, but it worked.

Thank you.

Deknor
21st August 2015, 06:31
:)Hi guys,

I also got the problem when to print data/array in report layout.

This is my sample code:

declaration:

table twhinp100
table twhwmd400
|table tcibd100
table ttcccp020

extern domain tctrns.date date.f
extern domain tctrns.date date.t
domain tcmcs.str10 header(5)
domain tctrns.date dat(5)
domain tctrns.date date1,date2,date3,date4,date5
domain tcqiv1 qty.issue(5), qty.receipt(5)


header.1:
before.layout:

|select whinp100.*
|from whinp100
|where whinp100.date inrange {:date.f} and{:date.t}
|order by whinp100.date

|selectdo

|datt = date.f

utc.add(utc.num(),0,0,-1,0,0,0,date1)
utc.add(utc.num(),0,0,-1,0,0,0,date2)
utc.add(utc.num(),0,0,-1,0,0,0,date3)
utc.add(utc.num(),0,0,-1,0,0,0,date4)
utc.add(utc.num(),0,0,-1,0,0,0,date5)


dat(1) = date1
dat(2) = date2
dat(3) = date3
dat(4) = date4
dat(5) = date5


header(1,1) = sprintf$("%u(%02d-%02m-%4Y)",dat(1))
header(1,2) = sprintf$("%u(%02d-%02m-%4Y)",dat(2))
header(1,3) = sprintf$("%u(%02d-%02m-%4Y)",dat(3))
header(1,4) = sprintf$("%u(%02d-%02m-%4Y)",dat(4))
header(1,5) = sprintf$("%u(%02d-%02m-%4Y)",dat(5))
|endselect


detail.1:
before.layout:

set.mem(qty.issue,0)
set.mem(qty.receipt,0)

qty.issue = whinp100.kotr.2
qty.receipt = whinp100.kotr.1

select whinp100.*
from whinp100
where whinp100.date inrange {:date.f} and{:date.t}
order by whinp100.date

if whinp100.date = dat(1)
if whinp100.kotr = 2
qty.issue = qty.issue(1) + whinp100.qana
else
qty.receipt = qty.receipt(1) + whinp100.qana
endif
else if
whinp100.date = dat(2)
if whinp100.kotr = 2
qty.issue = qty.issue(1) + whinp100.qana
else
qty.receipt = qty.receipt(1) + whinp100.qana
endif
else if
whinp100.date = dat(3)
if whinp100.kotr = 2
qty.issue = qty.issue(1) + whinp100.qana
else
qty.receipt = qty.receipt(1) + whinp100.qana
endif



I want to print data by the item with transaction date which is stored the quantity issue and receipt issue according date.f and date.t. But the header of report layout which is the date does not print the exact transaction date but it's print the current date which is today.

Here I attached the example of result what i get.

and also i attached the example of requirement what I want.

Your kindness i'm really appreciated,

bhushanchanda
21st August 2015, 11:14
Hi,

For this kind of layout, you should use before.field type of layout.

Use Item Code for before.field. For that, you will need to double click on the input field and change the sort mode to presorted. Also, its not possible to dynamically increase the date in the report. You will need to have fixed number of dates. e.g. 5

So, if your current date is 5th of August 2015, your header should be like

1st Aug 15, 2nd Aug 15, 3rd Aug 15, 4th Aug 15, 5th Aug 15
Issue 11 22 0 44 12
Receipt 0 2 14 44 2

Detail layout won't help in this case. You can create 3 before.field layouts -

before.whinp100.item.1 - This will have your dates
before.whinp100.item.2 - This will have Issue Quantities
before.whinp100.item.3 - This will have Receipt Quantities

Deknor
25th August 2015, 06:41
Hi,

For this kind of layout, you should use before.field type of layout.

Use Item Code for before.field. For that, you will need to double click on the input field and change the sort mode to presorted. Also, its not possible to dynamically increase the date in the report. You will need to have fixed number of dates. e.g. 5

So, if your current date is 5th of August 2015, your header should be like

1st Aug 15, 2nd Aug 15, 3rd Aug 15, 4th Aug 15, 5th Aug 15
Issue 11 22 0 44 12
Receipt 0 2 14 44 2

Detail layout won't help in this case. You can create 3 before.field layouts -

before.whinp100.item.1 - This will have your dates
before.whinp100.item.2 - This will have Issue Quantities
before.whinp100.item.3 - This will have Receipt Quantities





Hi,

That's mean, no need to put details layout in report. Is it correct?

bhushanchanda
25th August 2015, 08:01
Correct. Use Before.field/After.field layout for simplifying.