$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

Update/Delete UDO line

Jun 30, 2017 at 10:14 AM

305

avatar image

Hello everybody,

I would like to know how to update or delete a specific line on a user defined object through DI API

So far I have managed to

//get the UDO
oGeneralService = oCompanyService.GetGeneralService("someUserObject");
//select a specific line from header
oGeneralParams = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
oGeneralParams.SetProperty("DocEntry", 1);
oGeneralData = oGeneralService.GetByParams(oGeneralParams);
//select the lines table
oChildren = oGeneralData.Child("LinesTable");
//but when I try to get the specific line from line id I get an invalid row error
oChildren.Item(LineId).SetProperty(U_Field, "test");

//finally update our UDO,
oGeneralService.Update(oGeneralData);

If anyone could provide a correct way to go to a specific line of UDO's lines and edit/remove it I would be grateful.

Kind regards,

Dimitris Theotokatos

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
ANKIT CHAUHAN
Jun 30, 2017 at 10:34 AM
0

Hi,

Have you been able to check this?

UDO Update Data

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hello Ankit,

thank you for your reply.

My issue is not selecting a specific line from the UDO's header but selecting and editing/removing a line from a UDO's selected header lines table.

Kind regards,

Dimitris Theotokatos

0

Hi,

In the provided link, there is already a sample which shows you how to update data on a specific line.

If you do not have that requirement, kindly help to provide a screenshot.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

In the link provided if I select one of the links on selected answer, I get an error Page Not Found!

Can you please provide the updated links to the answers?

Kind regards,

Dimitris Theotokatos

0

Hi,

Following code is mentioned there in the link:

SAPbobsCOM.GeneralService oGeneralService = null;
SAPbobsCOM.GeneralData oGeneralData = null;
SAPbobsCOM.GeneralDataParams oGeneralParams = null;
SAPbobsCOM.CompanyService sCmp = null;
SAPbobsCOM.GeneralData oChild = null;
SAPbobsCOM.GeneralDataCollection oChildren = null;
sCmp = SBO_Company.GetCompanyService();
oGeneralService = sCmp.GetGeneralService("UDOCODE");
oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
oGeneralParams.SetProperty("Code", ANYCode);
oGeneralData = oGeneralService.GetByParams(oGeneralParams);
oChildren = oGeneralData.Child("DETAILTABLEOFUDO");
oChild = oChildren.Item(LineID - 1);
oChild.SetProperty("U_Field1", VALUETOSET1);
oChild.SetProperty("U_Field2", VALUETOSET2);
oGeneralService.Update(oGeneralData);

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

Solved my issue by using record number instead of line id in

oChildren.Item(LineId).SetProperty(U_Field, "test");

so the correct code looks like

oChildren.Item(line_count).SetProperty(U_Field, "test");

Thanks a lot for your help!

0
Danilo Kasparian Jun 30, 2017 at 01:03 PM
0

Hi,

See the code below, got from SDK help

Dim oGeneralService As SAPbobsCOM.GeneralService
Dim oGeneralParams As 
SAPbobsCOM.GeneralDataParams

Dim sCmp As SAPbobsCOM.CompanyService
sCmp = 
oCompany.GetCompanyService

'Get a handle to the 
SM_MOR UDO
oGeneralService = sCmp.GetGeneralService("SM_MOR")

'Delete UDO 
record
oGeneralParams = 
oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
oGeneralParams.SetProperty("DocEntry", "2")
oGeneralService.Delete(oGeneralParams)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi,

In your Subject, you have asked for Update/Delete both. Therefore, the Update script was provided.

Anyways, great to know that the issue has been solved for you!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0