cancel
Showing results for 
Search instead for 
Did you mean: 

How to add data in a matrix?

Former Member
0 Kudos

Hi forum!

I'm novice in programming with SAP, and I can't add data in a matrix.

This is my code



if ((pVal.FormTypeEx == "146") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.BeforeAction == true))
        {
            if (pVal.ItemUID == "112")
           {
                string sMonto = "3";
                oItem = oForm.Items.Item("112");
                oItem.Enabled = true;
                oMatrix = ((SAPbouiCOM.Matrix)(oItem.Specific));
                oColumns = oMatrix.Columns;
                oColumn = oColumns.Item("51");
                oColumn.Editable = true;
                oCell = oColumn.Cells.Item(1);
                oEditText = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText.Value = sMonto; 
             }
        }

Why this code is not valid?, What should do I for add a static data in a matrix?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Edy, I need the data because this program prints a ticket, and the ticket must include the differents way of pay. I need to catch the credit cards. Using the values added earlier I don't have problems, but the problem is How can I store the data of many credit cards?

Thanks

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Hahaha.... Sorry... even when i think i get you, still i missed your point... this is becoming more of like guessing games... haha...

Okay... my last shot...

You have already store the first credit card data in the previous code, now

You want to code, to store the second credit cards data. is it correct ?

If i am wrong again, I might as well give up.. sorry

Regards

Edy

Former Member
0 Kudos

Yes, you have the correct answer xD

You read my mind.

Greetings

Victor Navarro

edy_simon
Active Contributor
0 Kudos

At last....

Ok, After you input your first credit card data, you add this code to the bottom of the previous code


oItem = oForm.Items.Item("55"); 
oMatrix = oItem.Specific; 
oMatrix.Columns.Item("25").cells.item(2).Click(); 

Then you repeat the previous code for inputing the second credit card data.

That should work, again please excuse me C syntax....

Try it and let me know.

Regards

Edy

Former Member
0 Kudos

Don't worry with the syntax

That's a great idea, but on Monday I'll tell you my problems xD

Now I'm leaving my job.

Thanks a lot Edy, you solved my problems

Greetings, see you on Monday

Victor Navarro

Former Member
0 Kudos

Thanks Edy, you solved my problem.

The program really works, and the values is loaded automatically and I can save the pay with many cards.

Thank you very much Edy, I am very grateful of your help.

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Glad to be of help.

And thanks for your points

Regards

Edy

Answers (13)

Answers (13)

Former Member
0 Kudos

I know about the existences of these tables, but I was thinking, and the data should be stored in memory (I suppose) because this data is temporal, and the sale still has not being created.

Do you think in what place this data is "stored"?

Thank you Edy, and don't worry, your help has served me so much.

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Oh... I see.

But why would you want to retrieve this data back, since you are the one who put in the value ? Using the Code earlier ?

Anyway,

Since this data is in a matrix, there is no temporary memory to retrieve this. You can only get this data by accessing the matrix and reading from the column.

Regards

Edy

Former Member
0 Kudos

Mmmm...

I pay with two credit cards, the [first|http://i42.tinypic.com/t5q5q8.jpg] and the [second|http://i41.tinypic.com/149uv4j.jpg], but I don't know how catch the ammount and the type of card, that values is stored in "any place" and the matrix next to the card information only shows 2 cards. I need the amount too.

Do you understand me now?

Thank you so much Edy

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

The data for these transactions and cards, are stored in the ORCT and RCT3 Table.

You can access it through the recordset object.

Hope this is what you are asking....

Sorry...

Regards

Edy

Former Member
0 Kudos

Well, In my country we have many ways to pay a sale, specially with cards.

We have credit cards of banks, stores, supermarkets, debit cards,

and in a sale we can pay an amount with a bank card, and the rest with debit card.

The control is a simple matrix, but the row 2, in English is Define again.

I need to know where are stored the data of credit cards pay.

Thank you so much, my English is not good but I try to explain like I can.

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Victor,

Sorry, I still cannot quite understand what you are trying to get,

Are you trying to select the 2nd row (the Define new row) ?

If so, You can do it via


omatrix.Columns.Item("22").Cells.Item(2).Click;

Regards

Edy

Former Member
0 Kudos

The program works!

Thanks Edy

The problem with the combobox was solved, but I have another question.

¿How can I catch the pay with cards?

If I pay with many cards, these pays are stored in this control

Control

The localization is next to the trasposed matrix.

I don't know how is called this control and how catch values of this.

Regards

Victor Navarro

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Great..

Next..

I am sorry, I dont understand what you mean by catch the pay with cards ?

The item is a regular matrix without header and 1 column.

You can access it as a normal matrix.

Regards

edy

Former Member
0 Kudos

Edy, yesterday it was a bank holiday in my country (I'm Chilean) and I could not answer you.

Now I have a problem.

When I select an item of the combo in column 41, this value is ""

Look at this image: [Imagen|http://i42.tinypic.com/v8oehg.jpg]

If I have the description of the combo like "", the program does not works.

How can know I the value of the combo when I choose some of them?

The event is the COMBO_SELECT, but curiously I don't have the value of the combo.

In the new code I have added the values of the other Edit, but always going to be locked (Because the combo fails)

Regards

Victor Navarro

I don't know how to edit the wrong post.

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Of course the combo will give you a "" value, because you catch it in BeforeAction = True,

For combo_select, the value will be something only when BeforeAction = False.

Also in your code, I do not see you put in the value of Combo 65. without this value, the column 46 will always be locked.

BTW. you do not need to set the cells editable to True.. in system form, you cannot set this property.

And also, in system form, you do not need to bind it to any data source. it is done automatically by SBO.

here i try to edit your code, and repost it. But please excuse me if there is some typo or anything, Because I am not so fluent in C language.


if ((pVal.FormTypeEx == "146") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.BeforeAction == False) & (pVal.ColUID == "41")) 
{ if (pVal.ItemUID == "112") 
{ 
string sFecha = "10/10"; 
string sMonto = "CLP 3"; 
string sRut = "1-9"; 
string sTarj = "2567"; 
string sBodega = "CD"; 
oItem = oForm.Items.Item("112"); 
oMatrix = ((SAPbouiCOM.Matrix)(oItem.Specific)); 
oColumns = oMatrix.Columns; 
oColumn = oColumns.Item("41"); 
oCell = oColumn.Cells.Item(1); 
oComboBox = ((SAPbouiCOM.ComboBox)(oCell.Specific)); 
string sCombo = oComboBox.Selected.Description; 
oColumn = oColumns.Item("63"); 
oCell = oColumn.Cells.Item(1); 
oEditText = ((SAPbouiCOM.EditText)(oCell.Specific)); 
oEditText.Value = sTarj; 
oColumn = oColumns.Item("64"); 
oCell = oColumn.Cells.Item(1); 
oEditText = ((SAPbouiCOM.EditText)(oCell.Specific)); 
oEditText.Value = sFecha; 
oColumn = oColumns.Item("21"); 
oCell = oColumn.Cells.Item(1); 
oEditText2 = ((SAPbouiCOM.EditText)(oCell.Specific)); 
oEditText2.Value = sRut; 
oColumn = oColumns.Item("65");								'<---   Add these lines 
oCell = oColumn.Cells.Item(1);								'<---	Add these lines 
oCBO = ((SAPbouiCOM.ComboBox)(oCell.Specific));						'<---	Add these lines 
oCBO.select("*TCRD_3CUOTAS",SAPbouiCOM.BoSearchKey.psk_ByDescription);			'<---	Add these lines 
oColumn = oColumns.Item("46"); 
oCell = oColumn.Cells.Item(1); 
oEditText3 = ((SAPbouiCOM.EditText)(oCell.Specific)); 
oEditText3.Value = sMonto; 
oColumn = oColumns.Item("60"); 
oColumn.Editable = true; 
oCell = oColumn.Cells.Item(1); 
oEditText3 = ((SAPbouiCOM.EditText)(oCell.Specific)); 
oEditText3.Value = sBodega; 
}
}

In your code, i added some lines and deleted some lines.

Please try it and let me know.

Regards

edy

Former Member
0 Kudos

Edy, yesterday it was a bank holiday in my country (I'm Chilean) and I could not answer you. Now I have a problem.

When I select an item of the combo in column 41, this value is ""

Look at this image: [Imagen|http://i42.tinypic.com/v8oehg.jpg]

This is my new code:


if ((pVal.FormTypeEx == "146") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.BeforeAction == true) & (pVal.ColUID == "41"))
        {
            if (pVal.ItemUID == "112")
            {
                userDS = oForm.DataSources.UserDataSources.Add("montoPago", SAPbouiCOM.BoDataType.dt_SHORT_TEXT,20);

                string sFecha = "10/10";
                string sMonto = "CLP 3";
                string sRut = "1-9";
                string sTarj = "2567";
                string sBodega = "CD";

                oItem = oForm.Items.Item("112");
                oItem.Enabled = true;
                oMatrix = ((SAPbouiCOM.Matrix)(oItem.Specific));
                oColumns = oMatrix.Columns;

                oColumn = oColumns.Item("41");
                oCell = oColumn.Cells.Item(1);
                oComboBox = ((SAPbouiCOM.ComboBox)(oCell.Specific));
                string sCombo = oComboBox.Selected.Description;

                oColumn = oColumns.Item("63");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText.Value = sTarj;

                oColumn = oColumns.Item("64");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText.Value = sFecha;

                oColumn = oColumns.Item("21");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText2 = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText2.Value = sRut;

                oColumn = oColumns.Item("46");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText3 = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText3.Value = sMonto;

                oColumn = oColumns.Item("60");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText3 = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText3.Value = sBodega;
            }
        }

If I have the description of the combo like "", the program does not works.

How can know I the value of the combo when I choose some of them? The event is the COMBO_SELECT, but curiously I don't have the value of the combo.

In the new code I have agree the values of the other Edit,

but always going to be locked (Because the combo fails)

Regards

Victor Navarro

Former Member
0 Kudos

Edy, when I make a sale with a ticket, I have many ways to pay (money, credit card, check...),

the form 146 is the form to pay the sale, and the combo is for the credit card.

I don't know how post images here, so I put the links of them:

[Form 146|http://i39.tinypic.com/2zhlhcw.jpg]

The language of SBO in my enterprise is Spanish.

Well, answering the question 1, I added the code in the line 1, but I still have the error.

In the first image the combo has focused, and the value is showed in the bottom

And, with the question 2, please see this image

[Value 3|http://i41.tinypic.com/z4o4g.jpg]

My code is bad, and the column that I want to add the value is the 46.

Now I corrected the code and I have the error. The column 46 row 1 has focused and

I can insert the value "3" using SBO manually.

If you watch the images, you see the rows are vertically and

the columns horizontally (I don't know why)

And if you want to access to this form,

the [icon|http://i42.tinypic.com/2ivfvvc.jpg] (of the center) must to be activated.

Greetings.

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

OK, I've seen what you want to do.

Before you set the value of Item 46,

You have to set the Value of Combo in column 41 and Combo in column 64.

I've seen in your code that you/user have set the column 41. But have you set the combo in column 64 ?

Before setting a value to these both combo, the item 46 is locked. You cannot edit it,

Regards

Edy

BTW. The matrix item is a transposed matrix.

Edited by: Edy Simon on May 21, 2009 3:34 AM

Former Member
0 Kudos

Yes Edy, is a system form and the matrix too. If I can't bind it,

How should do I to add a static data in the system matrix?

Mi idea is, when I select an item of the combo, add values to the matrix.

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

Can you tell me what form is this 146 ?

Maybe I can get clearer picture if we are looking at the same thing.

I dont see anything wrong with the code you post orignally, except :

1. You are not specifying the pval.coluid of the combo box you are trying to catch the event in your first line.


if ((pVal.FormTypeEx == "146") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.BeforeAction == true) & (pval.ColUID= "???"))
        {
            if (pVal.ItemUID == "112")

2. If user is selecting the combo, you are trying to update matrix 112, column 51, row 1 to show Value '3'

Can you try to type in '3' into this column 51 row 1 using the SBO screen manually?

Please try it and let me know.

Regards

Edy

Former Member
0 Kudos

Well, my new code is this:



if ((pVal.FormTypeEx == "146") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) & (pVal.BeforeAction == true))
        {
            if (pVal.ItemUID == "112")
           {
                userDS = oForm.DataSources.UserDataSources.Add("montoPago", SAPbouiCOM.BoDataType.dt_SHORT_TEXT,20);
                
                string sMonto = "3";
                oItem = oForm.Items.Item("112");
                oItem.Enabled = true;
                oMatrix = ((SAPbouiCOM.Matrix)(oItem.Specific));
                oColumns = oMatrix.Columns;
                oColumn = oColumns.Item("51");
                oColumn.Editable = true;
                oColumn.DataBind.SetBound(true, "", "montoPago");
                oCell = oColumn.Cells.Item(1);
                oEditText = ((SAPbouiCOM.EditText)(oCell.Specific));
                oEditText.Value = sMonto;
            }
        }

But in the moment of set bound in the column, the program crashes. If I set bound in EditText, the program crash too. I don't know what to do

edy_simon
Active Contributor
0 Kudos

Hi Vitoko,

What is form 146 ? is it a system form ?

And Item 112 is your matrix or system matrix ?

If it is a system matrix, you cannot set bind it.

regards

edy

Former Member
0 Kudos

You need to have data sources behind most controls in sap b1 to have the value stored. Try it with a simple edittext - if you don't set the data source, after you leave the control (using tab or clicking somewhere else) the text you wrote is gone.

Former Member
0 Kudos

I was looking the sample, and I don't understand the binding. Why do I need to use binding to add a static value in a matrix?. The cell that I need to fill isn't related with a table (Amount of pay).

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

Vitoko,

Have a look at the documentation on matrices in the SAP Business One SDK Help Documentation under the UI API. Also there is a sample that comes with the SDK for Matrices and Datasources that you may want to review. You can find the sample if you have the SAP Business One SDK installed at ...

..\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\06.MatrixAndDataSources

Eddy

Former Member
0 Kudos

Did you bind your matrix to a datasource ?