The following snippets are meant to show how to extract the individual elements from a string with fixed separators.
Variant 1: Convert the string to a container using str2con()
static void Job1(Args _args) { str paramAsStr = "Wert1@@Wert2@@Wert3"; container paramAsCon; int i; paramAsCon = str2con(paramAsStr, "@@"); for (i=1;i<=conLen(paramAsCon);i++) { info(conPeek(paramAsCon, i)); } }
Variant 2: Convert the string to a list using strSplit()
static void Job1(Args _args) { str paramAsStr = "Value 1|Value 2|Value 3"; List paramAsList; ListEnumerator le; paramAsList = strSplit(paramAsStr, "|"); le = paramAsList.getEnumerator(); while(le.moveNext()) { info(le.current()); } }
l.addStart(“Tendulkar”); l.addEnd(“sehwag”); l.addEnd(“gambhir”); l.addEnd(“yuvraj”); l.addStart(“haribhajan”); l.addend(“haribhajan”); info(int2str(l.elements())); //length List.elements()
Vendor lock-in
eg:
static void DA_updateVendOnHold(Args _args) { List paramAsList; ListEnumerator le; VendTable d_vendTable; CustVendorBlocked _blocked = CustVendorBlocked::All; int i = 1,j = 1; str param = 'V000002,V000005,V000008,V000012,V000015,V000018,V000020,V000022,V000023,V000024,V000025,V000026,V000033,V000034,V000036,V000037,V000040,V000041,V000042,V000043,V000044,V000046,V000047,V000049,V000050,V000053,V000054,V000058,V000059,V000061,V000063,V000064,V000065,V000066,V000067,V000068,V000070,V000071,V000073,V000074,V000075,V000077,V000085,V000093,V000094,V000097,V000099,V000101,V000107,V000108,V000113,V000114,V000115,V000116,V000117,V000118,V000119,V000120,V000123,V000125,V000126,V000128,V000129,V000139,V000141,V000142,V000144,V000147,V000148,V000149,V000151,V000152,V000154,V000157,V000158,V000163,V000166,V000167,V000168,V000170,V000171,V000173,V000181,V000182,V000183,V000184,V000188,V000215,V000225,V000234,V000238,V000259,V000261,V000277,V000281,V000282,V000285,V000286,V000287,V000288,V000290,V000291,V000294,V000295,V000296,V000300,V000301,V000302,V000303,V000311,V000312,V000322,V000338,V000347,V000350,V000379,V000380,V000383,V000386,V000388,V000389,V000394,V000395,V000396,V000397,V000410,V000411,V000413,V000414,V000416,V000419,V000421,V000423,V000424,V000425,V000431,V000432,V000434,V000435,V000436,V000437,V000438,V000439,v000442,V000444,V000449,V000450,V000451,V000457,V000462,V000465,V000469,V000477,V000479,V000484,V000487,V000488,V000491,V000493,V000494,V000502,V000505,V000511,V000526,V000528,V000529,V000537,V000541,V000543,V000547,V000548,V000549,V000557,V000558,V000578,V000579,V000580,V000581,V000582,V000583,V000590,V000591,V000595,V000598,V000600,V000601,V000604,V000607,V000608,V000609,V000617,V000625,V000632,V000645,V000668,V000755,V000825,V000830,V000836,V000858,V000452,V000248,V000710,V000713,V000752,V000760,V000768,V000787,V000820,V000346,V000374,V000441,V000443,V000779,V000790,V000843'; paramAsList = strSplit(param,","); le = paramAsList.getEnumerator(); while(le.moveNext()) { ttsbegin; select forUpdate d_vendTable where d_vendTable.AccountNum ==le.current(); if(d_vendTable) { d_vendTable.Blocked = _blocked; d_vendTable.BlockedReleaseDate = DateTimeUtil::parse("2055-12-31T00:00:00"); d_vendTable.modifiedField(fieldNum(VendTable,Blocked)); d_vendTable.selectForUpdate(); d_vendTable.update(); info(strFmt("供应商:%1,数量:%2",le.current(),i)); i++; }else{ info(strFmt("无此供应商:%1,数量:%2",le.current(),j)); j++; } ttscommit; } }
留言评论
暂无留言