i am trying to map EDI 834 XSD with transaction tables in database.
I want to know some things
1> DO i need to take one expression transformation for one segment from 834 xsd means 1 expression for ISA, one for GS, one for ST and so on
2> whwn ever i am tring to join two expression through joiner, it is sotrting all the values which is disurbing every things
EX. there are 2 ST in one 834 input file and there are 2 INS coresponding to them
in EXP1
ST
123
547
and in EXP2
INS
549
963
they are in 2 expressions, now when i am trying to join these 2 expression through a dummy condition the output that i am getting is
ST INS
123 549
123 963
547 549
547 963
means there is no relation whether which INS belong to which ST
the output should be
ST INS
547 549
123 963
Is there any other solution to it.
Can someone plese tell me how can to do it
it seems that you are trying to extract native EDI message with powerCenter.
Informatica has a specific offering for EDI processing - a product called B2B DataExchange, which includes built in libraries for EDI messages, that will automatically convert the native EDI message to XML, which you could handle more easely using plain PowerCenter.
For more information, please refer to http://www.ablinkconsulting.com/what-do-we-do/edi-practice-solution/ , to find information on an EDI use case, and some informative blogs.
A.B Link offers a full service portfolio, focusing on architecture, analysis, implementation and consulting of Informatica B2B product suite
The problem would seem to be the dummy join condition is failing.
I suggest that in all of your input Expressions you add a port that acts as a row count.
Add a variable port V_COUNTER (Expression: IIF(V_COUNTER=0,1,V_COUNTER+1))
Add an output port O_COUNTER which outputs the value V_COUNTER
And you change you Joiner to join on these new O_COUNTER ports.
Related
I need to find all the records which contains the given sub-string(art), and the condition is the given substring is either a complete word within the string or the start of any word within the string.
Sample data. Program
id | name
-----------
10 | Report of Quarter 1
11 | The Art Program
12 | The Artificial Program
From the above data, I must be able to get the record numbers 11 and 12 but not 10.
I am trying like this
Program.where("name ~* ?",'art\b')
but it's not working
I have also tried with
Program.where("regexp_match(name, ?)",'/art\b/i')
this too is not working
any help is really appreciable. Thanks!
EDITED
I guess you are using Postgres since you gave an example with regexp_match
Try Program.where("name ~* ?",'\mart') :)
You can see hidden in the Postgres docs ("Regular Expression Escapes" section) that \b means "backspace, as in C" whereas \m "matches only at the beginning of a word"
As I'm new to cobol, please help me with the below piece of code.
WORKING-STORAGE SECTION.
01 BAS-REC.
02 INPT-REC.
49 INPT-LEN PIC S9(4) COMP.
49 INPT-TEXT PIC X(150).
02 INPT1-REC.
49 INPT1-LEN PIC S9(4) COMP.
49 INPT1-TEXT PIC X(150).
02 INPT2-REC.
49 INPT2-LEN PIC S9(4) COMP.
49 INPT2-TEXT PIC X(150).
77 VAR1 PIC X(5) VALUE 'APT'.
77 NUM1 PIC 9(1).
I'm using the level 49 for character varying here (to truncate trailing spaces)
Then I have cursor fetch.
After few modification under PROCEDURE DIVISION I'm doing the below.
PERFORM UNTIL SQLCODE=100
PERFORM VARYING NUM1 FROM 1 BY 1 UNTIL NUM1=6
STRING INPT-REC DELIMITED BY ' ',' ',
VAR1 DELIMITED BY ' ',' '
NUM1 DELIMITED BY ' ' INTO INPT2-REC
EXEC SQL
insert query here (which will run 5 times)
END-EXEC
END- PERFORM
END- PERFORM
but in the table the data got inserted only once but it shold have got inserted 5 times and also the INPT2-REC hasn't been concatenated. The INPT2 -REC just contains the value of INPT-REC alone
My question is this a special characteristic of level 49 or am I wrong somewhere?
Note that if you use INPT-REC2 as a host-variable for a VARCHAR-field you will only see the part from INPT-REC since you never update the length-field: it still contains the length it was assigned from INPT-REC.
So you'll have to somehow get the actual length of INPT2-TEXT (e.g. INSPECT the REVERSE of INPT2-TEXT for LEADING SPACES) and move it to INPT2-LENGTH before your EXEC SQL.
As I already said in my comment: there is nothing special about level 49 - you could as well use 48, 33,30 or 05 with the same results. The samples in the DB2 manual probably use 49 since it is the last valid level-number without any special meaning, so it is least likely to cause problems with any level-numbers already used in the program.
As for the query being executed only once: in your loop you are varying NUM1 but are checking whether I=6 - since we don't see I anywhere in your example I can only guess that it is already equal to 6 upon entering the loop.
Level 49 can be treated specially when Embedded SQL is involved, depending on system; this text is copied from the IBM Knowledge Center
Host structure declarations in COBOL must satisfy the following requirements:
COBOL host structures can have a maximum of two levels, even though the host structure might occur within a structure with multiple levels. However, you can declare a varying-length character string, which must be level 49.
A host structure name can be a group name whose subordinate levels name elementary data items.
If you are using the DB2® precompiler, do not declare host variables or host structures on any subordinate levels after one of the following items:
A COBOL item that begins in area A
Any SQL statement (except SQL INCLUDE)
Any SQL statement within an included member
When the DB2 precompiler encounters one of the preceding items in a host structure, it considers the structure to be complete.
So, this seems like a little implementation detail (level 49 for var char) that may spill over into other implementations of COBOL ESQL. Like many details buried in systems, Knowing that would require knowing that.
This particular detail is news to me as of a few minutes ago.
Looking more just now, this came up in the esqlOC contribution for GnuCOBOL recently. A level 49 specific tweak to ensure there was no need to worry about little end big end storage between host and service. So it seems to be a thing.
And an answer to the original question is; depends on compiler environment and ESQL preprocessor, but yeah maybe level 49 fields can be used for VARCHAR.
In different Forths, how do I customize the interpreter?
For example, in SP-Forth the interpreter always write the stack content and always make a CR/LF before printing:
1 2 3
Ok ( 1 2 3 )
.s
1 2 3 Ok ( 1 2 3 )
I would like to see:
1 2 3 ok
.s 1 2 3 ok
And generally, I would like to be able to define new data inputs like
4-3i
{1,2,3,4,5}
The interpreter should then store the data as I defined in the extension. Also, on errors I would like soft stacks and variables to be reset.
Any ideas?
In different Forth systems there are different ways for customization.
In SP-Forth you can define another action for OK vector. For example, to avoid printing data stack state:
: OK2 ( -- ) STATE # IF EXIT THEN ." ok" CR ;
' OK2 TO OK
\ see the original definition in src/compiler/spf_translate.f
Though, it is difficult to avoid CRLF before "ok" in Windows console application since this CRLF is part of the text that you input.
Regarding a new data formats there is Recognizers RfD. It is implemented in some Forth systems, but not in SP-Forth yet.
In SP-Forth you can use NOTFOUND mechanism to add custom word format (words interpreter).
I need to parse a text file that contains hundreds of records that span more than 1 line each. I'm new to Python and have been trying to do this with grep and awk in several complex ways but no luck yet.
The file contains records that look like this:
409547095517 911033 00:47:41 C44 00:47:46 D44 00:47:53 00:47:55
(555) 555-1212 00:47 10/31 100 Main Street - NW
Some_City TX 323 WRLS METRO PCS
P# 122-5217 ALT# 555-555-1212 LEC:MPCSI WIRELESS CALL Q
UERY CALLER FOR LOCATION QUERY CALLER FOR PHONE #*
Really I can do all I need to if I could just get these multi-line records condensed to 1 line per record. Each record will always begin with "40" or I could let 9110 indicate start as these will always be there and are unqiue providing 40 is at begining of line. I used a HEX editer and found that I could remove all line feeds (hex 0D0A) but this is not better than manually editing the files and programaticaly I'd need to not remove the last one per record. Some records will be only 2 lines but most will be 5 like this one.
Is there a way python or otherwise to concatonate the lines that make up a record into one line where 40 or maybe better choice where 9110 indicates the start of the record?
Any ideas or pointers will be much appreciated. I've got python and a good IDE and I'm good with grep and find but learning awk (don't laugh)...
awk will do it. You need to identify The line that starts a record. In this case it is 409547095517
So let's assume that to be safe if a line starts with 8 numbers it is the start of a record.
awk ' NR> 1 && /^[0-9]{8}/ { printf("\n") }
{printf("%s", $0) }
END{ printf("\n") }' filename > newfilename
Change the {8} to any number that works for you.
I'd like to build a poker hand-range parser, whereby I can provide a string such as the following (assume a standard 52-card deck, ranks 2-A, s = suited, o = offsuit):
"22+,A2s+,AKo-ATo,7d6d"
The parser should be able to produce the following combinations:
6 combinations for each of 22, 33, 44, 55, 66, 77, 88, 99, TT, JJ, KK, QQ, AA
4 combinations for each of A2s, A3s, A4s, A5s, A6s, A7s, A8s, A9s, ATs, AJs, AQs, AKs
12 combinations for each of ATo, AJo, AQo, AKo
1 combination of 7(diamonds)6(diamonds)
I think I know parts of the grammar, but not all of it:
NM+ --> NM, N[M+1], ... ,N[N-1]
NN+ --> NN, [N+1][N+1], ... ,TT where T is the top rank of the deck (e.g. Ace)
NP - NM --> NM, N[M+1], ... ,NP
MM - NN --> NN, [N+1][N+1], ..., MM
I don't know the expression for the grammar for dealing with suitedness.
I'm a programming newbie, so forgive this basic question: is this a grammar induction problem or a parsing problem?
Thanks,
Mike
Well you should probably look at EBNF to show your grammar in a widely accepted manner.
I think it would look something like this:
S = Combination { ',' Combination } .
Combination = Hand ['+' | '-' Hand] .
Hand = Card Card ["s" | "o"] .
Card = rank [ color ] .
Where {} means 0 or more occurences, [] means 0 or 1 occurence and | means either whats left of | or whats right of |.
So basically what this comes down to is a start symbol (S) that says that the parser has to handle from 1 to any number of combinations that are all separated by a ",".
These combinations consist of a description of a card and then either a "+", a "-" and another card description or nothing.
A card description consists of rank and optionally a color (spades, hearts, etc.). The fact that rank and color aren't capitalized shows that they can't be further divided into subparts (making them a terminal class).
My example doesn't provide the offsuite/suite possibility and that is mainly because in you're examples one time the o/s comes at the very end "AK-ATo" and one time in the middle "A2s+".
Are these examples your own creation or are they given to you from an external source (read: you can't change them)?
If you can change them I would strongly recommend placing those at one specified position of a combination (for example at the end) to make creating the grammar and ultimately the parsing a lot easier.