简体   繁体   English

使用函数确定延迟发货

[英]Determining Late Shipments with a Function

I am trying to write an if statement with 2 conditions.... one of them being if it has been longer than 60 minutes and the other condition is that it is "late".我正在尝试编写一个带有 2 个条件的 if 语句......其中一个是它是否已经超过 60 分钟,另一个条件是它“迟到”。 Example, I am trying to determine when shipments are late over an hour but I don't want it to count when shipments are early, just when they are late.例如,我试图确定发货延迟超过一个小时的时间,但我不希望它计算发货提前的时间,只计算延迟的时间。 Here is the equation I had originally buts its counting when shipments are greater than 60 minutes early as well:这是我最初使用的等式,但在发货提前 60 分钟以上时也计算在内:

IF HDIFF ( SHIPMENT_INDIVIDUAL_MOVE_COSTING.LOAD_DATE_FIELDS.SL_LD_DROP_ACTUAL_DATE , SHIPMENT_INDIVIDUAL_MOVE_COSTING.LOAD_DATE_FIELDS.SL_LD_DROP_APPT_START_DATE , 'Minute' , 'D6' ) GT 60 THEN 1 ELSE 0 

Any assistance or thoughts are appreciated.... I feel stuck任何帮助或想法表示赞赏....我觉得卡住了

I've tried some code with your problem, and I think it's working as intended.我已经针对您的问题尝试了一些代码,我认为它按预期工作。

The code I've used:我使用的代码:

-* IGNORE THESE LINES, ONLY FOR DATA SAMPLING
FILEDEF ORDERS DISK orders.ftm (APPEND
-RUN
-*
EX -LINES 6 EDAPUT MASTER,ORDERS,CV,FILE
FILENAME =ORDERS, SUFFIX=FIX
  SEGNAME=ORDERS, SEGTYPE=S0, $
    FIELD=ORDER_COD_PROD, ALIAS=ORDER_COD_PROD, USAGE=A21   ,ACTUAL=A1 ,$
    FIELD=ORDER_DELIVERY, ALIAS=ORDER_DELIVERY, USAGE=HYYMDS,ACTUAL=A30 ,$
    FIELD=ORDER_TRACKING, ALIAS=ORDER_TRACKING, USAGE=HYYMDS,ACTUAL=A30 ,$
-*
-WRITE ORDERS 12020/11/20 11:20              2020/11/20 12:45
-WRITE ORDERS 22020/11/20 11:40              2020/11/20 12:45
-WRITE ORDERS 32020/11/20 11:50              2020/11/20 12:45
-WRITE ORDERS 42020/11/20 11:55              2020/11/20 12:45
-WRITE ORDERS 52020/11/20 12:00              2020/11/20 12:45
-*
DEFINE FILE ORDERS
 HOW_LATE/D12.2 = HDIFF(ORDER_TRACKING, ORDER_DELIVERY, 'MINUTE', 'D12.2');
 DEC_LATE/A10   = IF HOW_LATE GE 60 THEN 'Late' ELSE 'Early';
END
-RUN
-*
TABLE FILE ORDERS
 PRINT 
  ORDER_COD_PROD AS 'ID'
  ORDER_DELIVERY AS 'Day/Time Compromised'
  ORDER_TRACKING AS 'Day/Time Now'
  HOW_LATE       AS 'Late (Minutes)'
  DEC_LATE       AS 'Late (Literal)' 
END
-RUN

The result is:结果是:

PÁG 1
ID  Day/Time Compromised    Day/Time Now         Late (Minutes) Late (Literal)
1   2020/11/20 11:20:00     2020/11/20 12:45:00  85,00          Late
2   2020/11/20 11:40:00     2020/11/20 12:45:00  65,00          Late
3   2020/11/20 11:50:00     2020/11/20 12:45:00  55,00          Early
4   2020/11/20 11:55:00     2020/11/20 12:45:00  50,00          Early
5   2020/11/20 12:00:00     2020/11/20 12:45:00  45,00          Early

This is fictitious data, but you can see I've created a file with several fields, one with product code, other with the time the product has to be delivered in Timestamp format, and lastly, other with a field that represents the "moment" of the report.这是虚构的数据,但您可以看到我创建了一个包含多个字段的文件,一个包含产品代码,另一个包含必须以时间戳格式交付产品的时间,最后一个包含代表“时刻”的字段”的报告。 With these 2 Timestamp we can use the function HDIFF to find the difference in minutes from both moments, as Double.有了这 2 个时间戳,我们可以使用函数 HDIFF 找到两个时刻的分钟差异,如 Double。 With this conversion, we can check if it's less than 60 min (LT) or greater or equal than 60 (GE).通过这种转换,我们可以检查它是否小于 60 分钟 (LT) 或大于或等于 60 (GE)。

Regards.问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM