Skip to main content

Locate record attribute using I-Descriptor

  • January 21, 2024
  • 3 replies
  • 0 views

Nelson Schroth

Looking for a way to locate the proper attribute in an output record where the appropriate data could end up on different attributes depending on conte

Example,  I 1st need to differentiate the type of record, which can be done with something like :

   IF INDEX(@ID,"WoJournal",1) THEN <acttion1> else if INDEX(@ID,"PoJournal",1) THEN <action2> ELSE <action3>

2nd, each action will need to find the proper attribute where the "STATUS" is logged.

Then it will need to extract the STATUS itself from the line which can use FIELD statements.

Looking for the best way to find the attribute # (2nd step) 



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

3 replies

John Jenkins
Forum|alt.badge.img+1
  • Participating Frequently
  • January 21, 2024

Looking for a way to locate the proper attribute in an output record where the appropriate data could end up on different attributes depending on conte

Example,  I 1st need to differentiate the type of record, which can be done with something like :

   IF INDEX(@ID,"WoJournal",1) THEN <acttion1> else if INDEX(@ID,"PoJournal",1) THEN <action2> ELSE <action3>

2nd, each action will need to find the proper attribute where the "STATUS" is logged.

Then it will need to extract the STATUS itself from the line which can use FIELD statements.

Looking for the best way to find the attribute # (2nd step) 



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

Nelson,

I'd be tempted to use a BASIC subroutine.

Regards

JJ



------------------------------
John Jenkins
Thame, Oxfordshire
------------------------------

Grant Boice
  • Participating Frequently
  • January 22, 2024

Looking for a way to locate the proper attribute in an output record where the appropriate data could end up on different attributes depending on conte

Example,  I 1st need to differentiate the type of record, which can be done with something like :

   IF INDEX(@ID,"WoJournal",1) THEN <acttion1> else if INDEX(@ID,"PoJournal",1) THEN <action2> ELSE <action3>

2nd, each action will need to find the proper attribute where the "STATUS" is logged.

Then it will need to extract the STATUS itself from the line which can use FIELD statements.

Looking for the best way to find the attribute # (2nd step) 



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

Nelson,

You could try the ESEARCH command on your data dictionary to help you search for what you are looking for.

It's not exactly pretty, but hopefully this will reduce your search time.

Hope this helps!



------------------------------
Grant Boice
Principal Software Developer
Matheson Tri-Gas Inc.
Warren, NJ 07059
------------------------------

Joseph von Arx
  • Participating Frequently
  • January 24, 2024

Looking for a way to locate the proper attribute in an output record where the appropriate data could end up on different attributes depending on conte

Example,  I 1st need to differentiate the type of record, which can be done with something like :

   IF INDEX(@ID,"WoJournal",1) THEN <acttion1> else if INDEX(@ID,"PoJournal",1) THEN <action2> ELSE <action3>

2nd, each action will need to find the proper attribute where the "STATUS" is logged.

Then it will need to extract the STATUS itself from the line which can use FIELD statements.

Looking for the best way to find the attribute # (2nd step) 



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

Nelson,

I agree with John Jenkins that a subroutine would probably be the better route; however, depending on the data, you could do some Tom Foolery like below:

DCOUNT(@RECORD[1,INDEX(@AM:NES(INDEXS(@RECORD, 'STATUS', 1), REUSE(0)):@AM, @AM:1:@AM, 1)], @AM)

This is assuming that there are no other system delimiters like @VM, @SVM, etcetera.  It does what you want but may be confusing to maintain by others.  I used @RECORD in my example for simplicity.

What my code does is a trick to replicate a LOCATE within an I-Descriptor.  I prepend and append whatever delimiter I am checking within, then do an index and find the first occurrence.  Afterward, I do a dcount of the original string using and my index result to determine how many delimiters exist.  This way, if I do not find the item, it returns a zero, otherwise, I get the position within the array.

X = INDEX('/some/delimited/variable/', '/':searchitem:'/', 1)

pos = DCOUNT(STRING[1,X], DELIMIN)

I hope it helps, but again, a subroutine is probably better.

Joseph



------------------------------
Joseph von Arx
Software Developer
Data Management Associates Inc DMA
Cincinnati OH US
------------------------------