当前位置:首页 » 期货交易 » sapabap日期货币校验
扩展阅读
股票投资经济学 2021-06-17 16:24:20

sapabap日期货币校验

发布时间: 2021-05-23 06:37:56

㈠ 在ABAP开发中如何获取选择日期前一个月的固定日期

没有实现的类,可以自己写一个。
这有一个类。你可以试一下:
package com;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.event.DocumentListener;
import javax.swing.text.DateFormatter;

import com.shiji.pastoral.common.arithmetic.CalculateDate;
import com.shiji.pastoral.common.arithmetic.GlobalStatus;
import com.shiji.pastoral.server.common.method.DebugPrint;

/**
* 日期控件
*
* @author 2008-5-23 上午11:38:14
*/
public class DatePanel extends JPanel {

private CalculateDate cal = new CalculateDate();

public JFormattedTextField hotelFormattedTextField;

public JButton dateButton;

private Window dialog;

private String labelName; // 每个Date的名称都不一样

private int x; // 跳出日期控件的x轴

private int y; // 跳出日期控件的y轴

public static String initDate = "1900-01-01";// CalculateDate.dateToString(CalculateDate.NULLDATE);

// // 系统默认Date

private boolean judge;

private String type = "-";

private static String time;

private JRadioButton enableRadioButton;

private boolean allowEmptyStr = true;// 是否允许文本框为空

public FocusAdapter f;

/**
* 系统初始化构造函数
*
* @author 2008-7-22 上午11:38:27
*
*/
public DatePanel() {
this(false);
}

public DatePanel(JDialog dialog) {
this(dialog, true);
}

public DatePanel(boolean showRadioBox) {
super();
dialog = DFrame.frame;
initGUI();
enableRadioButton.setVisible(showRadioBox);
}

/**
* 旧的方法,不建议使用,最终还是要删除的。。。by Jimmy
*
* @deprecated
* @param dialog
* @param labelName
* @param judge
*/
public DatePanel(Window dialog, String labelName, boolean judge,
boolean showRadioBox) {
super();
this.dialog = dialog;
this.labelName = labelName;
this.judge = judge;
initGUI();
enableRadioButton.setVisible(showRadioBox);
}

public DatePanel(Window dialog, String labelName, boolean judge) {
this(dialog, labelName, judge, false);
}

public DatePanel(Window dialog, boolean judge) {
super();
this.dialog = dialog;
this.labelName = "";
this.judge = judge;
initGUI();
enableRadioButton.setVisible(false);
}

private void initGUI() {

this.setPreferredSize(new java.awt.Dimension(139, 21));
BorderLayout thisLayout = new BorderLayout();
this.setLayout(thisLayout);
this.add(getDateButton(), BorderLayout.EAST);
this.add(getHotelFormattedTextField(), BorderLayout.CENTER);
this.add(getEnableRadioButton(), BorderLayout.WEST);

}

private JFormattedTextField getHotelFormattedTextField() {
// MaskFormatter mf = null;
// try {
// mf = new MaskFormatter("####-##-##");
// // mf.(false);
// } catch (Exception e) {
// e.printStackTrace();
// }

/*
* hotelFormattedTextField = new JFormattedTextField();
* hotelFormattedTextField.setDocument(new DateLimited(
* hotelFormattedTextField, new SimpleDateFormat("yyyy" + type + "MM" +
* type + "dd"))); hotelFormattedTextField.setText(initDate);
* hotelFormattedTextField.addFocusListener(new FocusAdapter() { public
* void focusLost(FocusEvent evt) { if
* (hotelFormattedTextField.getText().indexOf(" ") != -1 && judge) {
* JOptionPane.showMessageDialog(dialog, "Date is null!");
* hotelFormattedTextField.setText(" " + type + " " + type + " ");
* hotelFormattedTextField.requestFocus(); } } });
*/
// if(dateFormatType.trim().isEmpty()||dateFormatType==null)
// dateFormatType = CalculateDate.dateFormatType;// "yyyy-MM-dd";
DateFormat dateFormat = new SimpleDateFormat(
CalculateDate.dateFormatType);
DateFormatter df = new DateFormatter(dateFormat);
hotelFormattedTextField = new JFormattedTextField(df);
hotelFormattedTextField
.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
hotelFormattedTextField.setBorder(new SoftBevelBorder(
BevelBorder.LOWERED, null, null, null, null));
hotelFormattedTextField.setFont(new java.awt.Font(null, 1, 12));
hotelFormattedTextField.setValue(CalculateDate.HotelDate);
if (allowEmptyStr)
hotelFormattedTextField.setText("");// 设置为空时间
else
hotelFormattedTextField.setValue(CalculateDate.HotelDate);
hotelFormattedTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent evt) {
if (hotelFormattedTextField.getText().trim().isEmpty()
&& allowEmptyStr) {
// DebugPrint.onePrint("现在输入的是空串");
hotelFormattedTextField
.setFocusLostBehavior(JFormattedTextField.PERSIST);// 不执行任何操作,不获取新的
// AbstractFormatter
// 也不更新该值。
} else {
hotelFormattedTextField
.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);// 恢复显示以匹配
// getValue,这可能丢失当前的编辑内容
if (hotelFormattedTextField.isEditValid()) {
// DebugPrint.onePrint("现在输入的是有效值");
hotelFormattedTextField.setFocusLostBehavior(JFormattedTextField.PERSIST);
if (CalculateDate.isNullDate(getDate())) {
// DebugPrint.onePrint("现在输入的时间是空时间");
hotelFormattedTextField.setText("");
}else if(getDate().compareTo(CalculateDate.NULLDATE)<0){
DefinedOptionPane.showMessageDialog(null,GlobalStatus.lang("Invalid Date can't less than 1900-01-01"), 1);
setDate(CalculateDate.getHotelDate(GlobalStatus.userStructure.getHotelID()));
}else if(getDate().compareTo(CalculateDate.MAXDATE)>0){
DefinedOptionPane.showMessageDialog(null,GlobalStatus.lang("Invalid Date can't more than 3000-12-31"), 1);
setDate(CalculateDate.getHotelDate(GlobalStatus.userStructure.getHotelID()));
}
} else {
if (!hotelFormattedTextField.getText().trim().isEmpty()) {
// DebugPrint.onePrint("现在输入的是无法效值");
DefinedOptionPane
.showMessageDialog(null,
GlobalStatus.lang("Invalid Date: ")
+ hotelFormattedTextField
.getText(), 1);
// hotelFormattedTextField.setText(initDate);
}
}

}
}
});

return hotelFormattedTextField;
}

private int getX(MouseEvent evt) {
int x1 = evt.getXOnScreen() - evt.getX()
- hotelFormattedTextField.getWidth();
int x2 = DFrame.width - CalendarDialog.width;
DebugPrint.jimmyPrintMsg(x1, x2);
return x1 > 0 ? Math.min(x1, x2) : 0;
}

private int getY(MouseEvent evt) {
int y1 = evt.getYOnScreen() + dateButton.getHeight() - evt.getY();
int y2 = DFrame.height - CalendarDialog.height;
if (y1 > y2)
y1 = evt.getYOnScreen() - evt.getY() - CalendarDialog.height;
return y1;
}

private JButton getDateButton() {
if (dateButton == null) {
dateButton = new JButton();
dateButton.setIcon(new ImageIcon(getClass().getClassLoader()
.getResource("img/down.png")));
dateButton.setPreferredSize(new java.awt.Dimension(20, 21));
dateButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
x = getX(evt);
y = getY(evt);
}
});
dateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
time = CalculateDate.dateToString(new CalendarDialog(
dialog, x, y, getDate()).getDate());
} catch (RuntimeException e) {
time = CalculateDate.dateToString(new CalendarDialog(
dialog, x, y, new Date()).getDate());
}
hotelFormattedTextField.setText(time.length() == 10
? time
: initDate);
hotelFormattedTextField.requestFocus();
time = initDate;
}
});
}
return dateButton;
}

/**
* 设置日期..不推荐用这个。。没测试过one
*
* @author 2008-8-5 上午10:37:33
*
* @param date
*/
public void setDate(String date) {
// setDate(new CalculateDate().stringToDate(date));
// hotelFormattedTextField.setValue(CalculateDate.dateFormat(new
// CalculateDate().stringToDate(date), dateFormatType));
if (date.trim().isEmpty())
hotelFormattedTextField.setText("");
else
setDate(CalculateDate.stringToDateExp(date));
}

public String getText() {
return CalculateDate.dateToString(getDate());
}

/**
* 获取日期
*
* @author 2008-8-5 上午10:37:46
*
* @return
*/
public Date getDate() {
// Date returndate;
// returndate = new CalculateDate().stringToDate(hotelFormattedTextField
// .getText());
if (hotelFormattedTextField.getText().trim().isEmpty()) {
// DebugPrint.onePrint("现在的日期是" + cal.stringToDate("1900-01-01"));
return cal.stringToDate("1900-01-01");
} else {
// DebugPrint.onePrint("现在的日期是"+
// cal.stringToDate(hotelFormattedTextField.getText()));
return cal.stringToDate(hotelFormattedTextField.getText());
}
}

/**
*
*
* @author Administrator 2008-9-16 下午02:33:24
*
* @param date
*/
public void setDate(Date date) {
// hotelFormattedTextField.setText(date != null ? new CalculateDate()
// .dateToString(date) : initDate);
if (CalculateDate.isNullDate(date))
hotelFormattedTextField.setText("");
else
hotelFormattedTextField.setText(CalculateDate.dateToString(date));
}

/**
* 设置文本框是否能为空
*
* @author One 2009-6-4上午10:09:14
*
* @param allow
*/
public void setAllowEmptyStr(boolean allow) {
allowEmptyStr = allow;
}

/**
* 设置错误日期的颜色
*
* @author One 2009-6-10下午04:27:58
*
* @param error
*/
public void setColour(boolean error) {
if (error)
hotelFormattedTextField.setForeground(Color.RED);
else
hotelFormattedTextField.setForeground(Color.BLACK);

}

@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
hotelFormattedTextField.setEnabled(enabled);
dateButton.setEnabled(enabled);
enableRadioButton.setSelected(enabled);
}

private JRadioButton getEnableRadioButton() {
if (enableRadioButton == null) {
enableRadioButton = new JRadioButton();
enableRadioButton.setSelected(true);
enableRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
setEnabled(enableRadioButton.isSelected());
}
});
}
return enableRadioButton;
}

public static void main(String[] args) {
JDialog frame = new JDialog();
frame.getContentPane().add(new DatePanel());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}

/**
* @author rainbow 2009-7-14 下午12:01:55
* @param listener
*
*/
public void addDocumentListener(DocumentListener listener) {
hotelFormattedTextField.getDocument().addDocumentListener(listener);
}

/**
* @author rainbow 2009-7-14 下午12:01:58
* @param listener
*
*/
public void removeDocumentListener(DocumentListener listener) {
hotelFormattedTextField.getDocument().removeDocumentListener(listener);
}
}

㈡ abap 中 select 语句 s_month(选择屏幕输入,列如:201612(年度加上期间)) A IN S_MONTH(前四位值),

另外定义两个选择变量。
RANGES:S_A FOR BKPF-GJAHR,
S_B FOR BKPF-MONAT.
根据输入信息给两个选择变量赋值
LOOP AT s_month.
S_A-SIGN = S_MONTH-SIGN.
S_A-OPTION = S_MONTH-OPTION.
S_A-LOW = S_MONTH-LOW+0(4).
S_A-HIGH = S_MONTH-HIGH+0(4).
APPEND S_A.
S_B-SIGN = S_MONTH-SIGN.
S_B-OPTION = S_MONTH-OPTION.
S_B-LOW = S_MONTH-LOW+4(2).
S_B-HIGH = S_MONTH-HIGH+4(2).
APPEND S_B.
ENDLOOP.
然后得到的选择变量取值
A IN S_A
B IN S_B

㈢ ABAP 日期条件问题请教

别写NOT BETWEEN,写了很容易造成Full table scan,效率太差

㈣ ABAP如何检查字符串是否为日期或时间格式

1、底下函数是检查日期的合法性的函数
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc NE 0. "如果返回非0,则日期不合法
.
.
ENDIF.

2、底下函数是检查时间合法性的函数
CALL FUNCTION 'TIME_CHECK_PLAUSIBILITY'
EXPORTING
time = v_time
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc NE 0. "如果返回非0,则时间不合法
.
.
ENDIF.

㈤ abap取得系统日期之前几个月

sy-datum+4(2)

㈥ 请教问题:ABAP中的币别转换

SAP中的货币转换函数:CURRENCY_CONVERTING_FACTOR【CURRENCY_CONVERTING_FACTOR】在SAP系统中,对于曰币、韩币这类特殊货币的处理是有特殊规则的。 具体的处理逻辑为:首先根据币别到DB表TCURX中读取相应的小数位数CURRDEC。如果没有维护相应币别信息则默认CURRDEC = 2。如果 CURRDEC GT 5.就报错。然后默认转换比率是100。在CURRDEC NE 0的情况下循环CURRDEC次,每次将转换比率除以10 。 所以如果表TCURX中的CURRDEC = 0就默认转换比率为100。当表TCURX中没有找到相应数据时则默认CURRDEC = 2。转换比率也就是100 / 10 / 10 = 1.其他的比如如果表TCURX中的CURRDEC = 4,则转换比率应该为 100 / 10 / 10 / 10 / 10 = 0.01我们在SE16中看到的货币金额基本上都经过了这个转换,如曰元,都是除以100后存入数据库的。所以当我们从数据库中读取曰元金额时也应该作相应的转换,乘以100 。简单的使用Function CURRENCY_CONVERTING_FACTOR。输入币别,就可以得到相应的转换比率了。 函数中所涉及的常用选项:EXPORTING: CURRENCY: 将被处理的货币种别编号IMPORTING: FACTOR: 转换后得到的货币比率 示范代码:FORM BRF_AP USING F_BETRAG "金额 F_CURRENCY. " 货币代码DATA: S_FACTORTYPEP DECIMALS 3.CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR' EXPORTING CURRENCY = F_CURRENCY IMPORTING FACTOR = S_FACTOR EXCEPTIONS TOO_MANY_DECIMALS = 1 OTHERS = 2.IF S_FACTOR NE 0. F_BETRAG = F_BETRAG / S_FACTOR.ENDIF.ENDFORM. 到思互圈子网站查看回答详情>>

㈦ SAP ABAP如何解决外系统输入日期的问题

标准的做法是事先跟外系统约定日期格式,一旦确定以后,不符合格式的数据一律视为非法数据。

㈧ SAP ABAP 显示年月日时分秒的数据类型

这是年月日时分秒在一个字段的数据类型
DATA: lv_timestamp TYPE timestamp. "UTC Time Stamp in Short Form (YYYYMMDDhhmmss)
GET TIME STAMP FIELD lv_timestamp.
WRITE:/ lv_timestamp.

不过还是定义两个字段,一个日期一个时间,一般都用这种
然后用sy-datum和sy-uzeit获取的系统服务器时区时间比较方便

㈨ SAP提示不能按日期确定来自RMB的汇率,这个问题怎么解决

汇率是波动的,一般企业会月度维护当月的成本结算汇率。
按你图所示,错误发生的原因是:没有维护3月的汇率。

㈩ SAP 定价日期跟发票校验什么关系

在开票条件中使用