Description
This method parse the prodataset passed from outside and insert the PayformatType,PayformatGroup,PayformatCode into the Database.
This method was created for EDI Program usage.
Parameters
izProdsPaymentFormat | input | dataset-handle | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bpaymentformat.p)
/* ================================================================= */
/* API method invoked By EDI Program
This method parse the prodataset passed from EDI and insert the
PayformatType,PayformatGroup,PayformatCode into the
Database */
/* ================================================================= */
assign
vhPayformatType = izProdsPaymentFormat:get-buffer-handle(1)
vhPayFormatGroup = izProdsPaymentFormat:get-buffer-handle(2)
vhPayFormatCode = izProdsPaymentFormat:get-buffer-handle(3).
create query vhQueryGroup in widget-pool "non-persistent".
vhQueryGroup:add-buffer(vhPayformatGroup).
/*vhQueryGroup:query-prepare("for each " + vhPayFormatGroup:table). */
create query vhQueryCode in widget-pool "non-persistent".
vhQueryCode:add-buffer(vhPayformatCode).
create query vhQuery in widget-pool "non-persistent".
vhQuery:add-buffer(vhPayformatType).
vhQuery:query-prepare("for each " + vhPayFormatType:table).
vhQuery:query-open().
vhQuery:get-first(no-lock).
repeat while not vhQuery:Query-Off-End:
vcPayformatTypeCode = vhPayformatType:buffer-field("PayformatTypeCode":U):buffer-value.
<Q-1 run PayFormatTypeByType (all) (Read) (NoCache)
(input vcPayFormatTypeCode, (PayFormatTypeCode)
output dataset tqPayFormatTypeByType) in BPaymentFormat >
find first tqPayFormatTypeByType no-error.
if not available tqPayformatTypeByType
then do:
<M-2 run AddDetailLine
(input 'PayformatType':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayformatType
then do:
assign
tPayFormatType.PayFormatTypeCode = vhPayformatType:buffer-field("PayformatTypeCode":U):buffer-value
tPayFormatType.Currency_ID = vhPayformatType:buffer-field("Currency_ID":U):buffer-value
tPayFormatType.PayFormatTypeIsActive = vhPayformatType:buffer-field("PayformatTypeIsActive":U):buffer-value
tPayFormatType.PayFormatTypeOutFilemask = vhPayformatType:buffer-field("PayformatTypeOutFileMask":U):buffer-value
tPayFormatType.PayFormatTypeModule = vhPayformatType:buffer-field("PayformatTypeModule":U):buffer-value
tPayFormatType.PayFormatTypePayType = vhPayformatType:buffer-field("PayformatTypepayType":U):buffer-value
tPayFormatType.PayFormatTypePayInstrument = vhPayformatType:buffer-field("PayformatTypePayInstrument":U):buffer-value
tPayFormatType.PayFormatTypeDescription = vhPayformatType:buffer-field("PayformatTypeDescription":U):buffer-value
tPayFormatType.PayFormatTypeLinesPerPage = vhPayformatType:buffer-field("PayFormatTypeLinesPerPage":U):buffer-value
tPayFormatType.PayFormatTypeSubSystem = vhPayformatType:buffer-field("PayFormatTypeSubSystem"):buffer-value
tPayFormatType.PayFormatTypeTPAddress = vhPayformatType:buffer-field("PayFormatTypeTPAddress"):buffer-value
tPayFormatType.PayFormatTypeTPSite = vhPayformatType:buffer-field("PayFormatTypeTPSite"):buffer-value
tPayFormatType.PayFormatTypeIsSEPA = vhPayformatType:buffer-field("PayFormatTypeIsSEPA"):buffer-value.
end.
vhQueryGroup:query-prepare("for each " + vhPayFormatGroup:table + " where PayFormatTypeCode = '" + vcPayformatTypeCode + "'").
vhQueryGroup:query-open().
vhQueryGroup:get-first(no-lock).
repeat while not vhQueryGroup:QUERY-OFF-END:
viPayformatGroupID = vhPayFormatGroup:buffer-field("PayformatGroup_ID":U):buffer-value.
<M-4 run AddDetailLine
(input 'PayformatGroup':U (icTable),
input tPayFormatType.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayformatGroup
then do:
assign
tPayFormatGroup.PayformatTypeCode = vhPayFormatGroup:buffer-field("PayformatTypeCode":U):buffer-value
tPayFormatGroup.PayformatGroupSequence = vhPayFormatGroup:buffer-field("PayformatGroupSequence":U):buffer-value
tPayFormatGroup.PayformatGroupDescription = vhPayFormatGroup:buffer-field("PayformatGroupDescription":U):buffer-value
tPayFormatGroup.PayformatGroupIsActive = vhPayFormatGroup:buffer-field("PayformatGroupIsActive":U):buffer-value
tPayFormatGroup.PayformatGroupCode = vhPayFormatGroup:buffer-field("PayformatGroupCode":U):buffer-value
tPayFormatGroup.PayformatGroupDataType = vhPayFormatGroup:buffer-field("PayformatGroupDataType":U):buffer-value
tPayFormatGroup.PayformatGroupIsMandatory = vhPayFormatGroup:buffer-field("PayformatGroupIsMandatory":U):buffer-value
tPayFormatGroup.PayformatGroupInputOption = vhPayFormatGroup:buffer-field("PayformatGroupInputOption":U):buffer-value
tPayFormatGroup.PayformatGroupLevel = vhPayFormatGroup:buffer-field("PayformatGroupLevel":U):buffer-value.
end.
vhQueryCode:query-prepare("for each " + vhPayFormatCode:table + " where PayFormatGroup_ID = " + String(viPayformatGroupID)).
vhQueryCode:query-open().
vhQueryCode:get-first(no-lock).
repeat while not vhQueryCode:Query-Off-End:
<M-6 run AddDetailLine
(input 'PayformatCode':U (icTable),
input tPayFormatGroup.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayFormatCode
then do:
assign
tPayFormatCode.PayFormatGroup_ID = tPayFormatGroup.PayformatGroup_ID
tPayFormatCode.PayFormatCode = vhPayformatCode:buffer-field("PayformatCode":U):buffer-value
tPayFormatCode.PayFormatCodeIsActive = vhPayformatCode:buffer-field("PayformatCodeIsActive":U):buffer-value
tPayFormatCode.PayFormatCodeDescription = vhPayformatCode:buffer-field("PayformatCodeDescription":U):buffer-value
tPayFormatCode.PayFormatCodeIsDefault = vhPayformatCode:buffer-field("PayformatCodeIsDefault":U):buffer-value.
end.
vhQueryCode:get-next(no-lock).
end. /*if not vhQueryCode:Query-Off-End*/
vhQueryGroup:get-next(no-lock).
end. /*if not vhQueryGroup:Query-Off-End */
end. /*if not available tqPayformatTypePrim*/
else do:
<M-7 run DataLoad
(input '':U (icRowids),
input vcPayformatTypecode (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
find first tPayFormatType where tPayformatType.PayFormatTypeCode = vcPayformatTypecode no-error.
assign tPayFormatType.tc_Status = "C":U.
if available tPayformatType
then do:
assign
tPayFormatType.Currency_ID = vhPayformatType:buffer-field("Currency_ID":U):buffer-value
tPayFormatType.PayFormatTypeIsActive = vhPayformatType:buffer-field("PayformatTypeIsActive":U):buffer-value
tPayFormatType.PayFormatTypeOutFilemask = vhPayformatType:buffer-field("PayformatTypeOutFileMask":U):buffer-value
tPayFormatType.PayFormatTypeModule = vhPayformatType:buffer-field("PayformatTypeModule":U):buffer-value
tPayFormatType.PayFormatTypePayType = vhPayformatType:buffer-field("PayformatTypepayType":U):buffer-value
tPayFormatType.PayFormatTypePayInstrument = vhPayformatType:buffer-field("PayformatTypePayInstrument":U):buffer-value
tPayFormatType.PayFormatTypeDescription = vhPayformatType:buffer-field("PayformatTypeDescription":U):buffer-value
tPayFormatType.PayFormatTypeLinesPerPage = vhPayformatType:buffer-field("PayFormatTypeLinesPerPage":U):buffer-value
tPayFormatType.PayFormatTypeSubSystem = vhPayformatType:buffer-field("PayFormatTypeSubSystem"):buffer-value
tPayFormatType.PayFormatTypeTPAddress = vhPayformatType:buffer-field("PayFormatTypeTPAddress"):buffer-value
tPayFormatType.PayFormatTypeTPSite = vhPayformatType:buffer-field("PayFormatTypeTPSite"):buffer-value
tPayFormatType.PayFormatTypeIsSEPA = vhPayformatType:buffer-field("PayFormatTypeIsSEPA"):buffer-value.
end.
vhQueryGroup:query-prepare("for each " + vhPayFormatGroup:table + " where PayFormatTypeCode = '" + vcPayformatTypeCode + "'").
vhQueryGroup:query-open().
vhQueryGroup:get-first(no-lock).
repeat while not vhQueryGroup:Query-Off-End:
viPayformatGroupID = vhPayFormatGroup:buffer-field("PayformatGroup_ID":U):buffer-value.
find first tPayFormatGroup where tPayFormatGroup.PayFormatGroupCode = String(vhPayFormatGroup:buffer-field("PayformatGroupCode":U):buffer-value) no-error.
if not available tPayFormatGroup
then do:
<M-8 run AddDetailLine
(input 'PayformatGroup':U (icTable),
input tPayFormatType.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayformatGroup
then do:
assign
tPayFormatGroup.PayformatTypeCode = vhPayFormatGroup:buffer-field("PayformatTypeCode":U):buffer-value
tPayFormatGroup.PayformatGroupSequence = vhPayFormatGroup:buffer-field("PayformatGroupSequence":U):buffer-value
tPayFormatGroup.PayformatGroupDescription = vhPayFormatGroup:buffer-field("PayformatGroupDescription":U):buffer-value
tPayFormatGroup.PayformatGroupIsActive = vhPayFormatGroup:buffer-field("PayformatGroupIsActive":U):buffer-value
tPayFormatGroup.PayformatGroupCode = vhPayFormatGroup:buffer-field("PayformatGroupCode":U):buffer-value
tPayFormatGroup.PayformatGroupDataType = vhPayFormatGroup:buffer-field("PayformatGroupDataType":U):buffer-value
tPayFormatGroup.PayformatGroupIsMandatory = vhPayFormatGroup:buffer-field("PayformatGroupIsMandatory":U):buffer-value
tPayFormatGroup.PayformatGroupInputOption = vhPayFormatGroup:buffer-field("PayformatGroupInputOption":U):buffer-value
tPayFormatGroup.PayformatGroupLevel = vhPayFormatGroup:buffer-field("PayformatGroupLevel":U):buffer-value.
end.
vhQueryCode:query-prepare("for each " + vhPayFormatCode:table + " where PayFormatGroup_ID = " + String(viPayformatGroupID)).
vhQueryCode:query-open().
vhQueryCode:get-first(no-lock).
repeat while not vhQueryCode:QUERY-OFF-END:
<M-9 run AddDetailLine
(input 'PayformatCode':U (icTable),
input tPayFormatGroup.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayFormatCode
then do:
assign
tPayFormatCode.PayFormatGroup_ID = tPayFormatGroup.PayformatGroup_ID
tPayFormatCode.PayFormatCode = vhPayformatCode:buffer-field("PayformatCode":U):buffer-value
tPayFormatCode.PayFormatCodeIsActive = vhPayformatCode:buffer-field("PayformatCodeIsActive":U):buffer-value
tPayFormatCode.PayFormatCodeDescription = vhPayformatCode:buffer-field("PayformatCodeDescription":U):buffer-value
tPayFormatCode.PayFormatCodeIsDefault = vhPayformatCode:buffer-field("PayformatCodeIsDefault":U):buffer-value.
end.
vhQueryCode:get-next(no-lock).
end. /*if not vhQueryCode:Query-Off-End*/
end. /* tPayFormatGroup.PayFormatGroupCode <> String(vhPayFormatGroup:buffer-field("PayformatGroupCode":U):buffer-value) */
else do:
tPayFormatGroup.tc_Status = 'C':U.
assign
tPayFormatGroup.PayformatGroupSequence = vhPayFormatGroup:buffer-field("PayformatGroupSequence":U):buffer-value
tPayFormatGroup.PayformatGroupDescription = vhPayFormatGroup:buffer-field("PayformatGroupDescription":U):buffer-value
tPayFormatGroup.PayformatGroupIsActive = vhPayFormatGroup:buffer-field("PayformatGroupIsActive":U):buffer-value
tPayFormatGroup.PayformatGroupDataType = vhPayFormatGroup:buffer-field("PayformatGroupDataType":U):buffer-value
tPayFormatGroup.PayformatGroupIsMandatory = vhPayFormatGroup:buffer-field("PayformatGroupIsMandatory":U):buffer-value
tPayFormatGroup.PayformatGroupInputOption = vhPayFormatGroup:buffer-field("PayformatGroupInputOption":U):buffer-value
tPayFormatGroup.PayformatGroupLevel = vhPayFormatGroup:buffer-field("PayformatGroupLevel":U):buffer-value.
vhQueryCode:query-prepare("for each " + vhPayFormatCode:table + " where PayFormatGroup_ID = " + String(viPayformatGroupID)).
vhQueryCode:query-open().
vhQueryCode:get-first(no-lock).
repeat while not vhQueryCode:Query-Off-End:
find first tPayFormatCode where tPayFormatCode.PayFormatCode = STRING(vhPayformatCode:buffer-field("PayformatCode":U):buffer-value) no-error.
if not available tPayFormatCode
then do:
<M-10 run AddDetailLine
(input 'PayformatCode':U (icTable),
input tPayFormatGroup.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if available tPayFormatCode
then do:
assign
tPayFormatCode.PayFormatGroup_ID = tPayFormatGroup.PayformatGroup_ID
tPayFormatCode.PayFormatCode = vhPayformatCode:buffer-field("PayformatCode":U):buffer-value
tPayFormatCode.PayFormatCodeIsActive = vhPayformatCode:buffer-field("PayformatCodeIsActive":U):buffer-value
tPayFormatCode.PayFormatCodeDescription = vhPayformatCode:buffer-field("PayformatCodeDescription":U):buffer-value
tPayFormatCode.PayFormatCodeIsDefault = vhPayformatCode:buffer-field("PayformatCodeIsDefault":U):buffer-value.
end.
end. /* if not available tpayformatcode */
else do:
tPayFormatCode.tc_Status = 'C':U.
assign
tPayFormatCode.PayFormatGroup_ID = tPayFormatGroup.PayformatGroup_ID
tPayFormatCode.PayFormatCode = vhPayformatCode:buffer-field("PayformatCode":U):buffer-value
tPayFormatCode.PayFormatCodeIsActive = vhPayformatCode:buffer-field("PayformatCodeIsActive":U):buffer-value
tPayFormatCode.PayFormatCodeDescription = vhPayformatCode:buffer-field("PayformatCodeDescription":U):buffer-value
tPayFormatCode.PayFormatCodeIsDefault = vhPayformatCode:buffer-field("PayformatCodeIsDefault":U):buffer-value.
end.
vhQueryCode:get-next(no-lock).
end. /*if not vhQueryCode:Query-Off-End*/
end.
vhQueryGroup:get-next(no-lock).
end. /* if not vhQueryGroup:Query-Off-End */
end. /* else do */
vhQuery:get-next(no-lock).
end.
vhQuery:Query-close().
vhQueryGroup:Query-close().
vhQueryCode:Query-close().
delete object vhQuery.
delete object vhQueryGroup.
delete object vhQueryCode.
<M-11 run ValidateBC
(output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
<M-12 run AdditionalUpdates
(output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
<M-13 run DataSave
(output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.