关于IAS REPORT的 REP-3000的错误解决

本文档详细介绍了REP-3000错误的原因及解决方案,包括设置DISPLAY环境变量的方法,不同环境下(如Web、Oracle Forms等)的调试步骤,以及针对不同Oracle Reports版本的具体建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天装IAS Report时又遇到了一个REP-3000的错误,调试了三个小时,才发现是一个环境变量配置的问题。

DISPLAY=<hostname>:0.0;export DISPLAY

这个hostname可以由机器的IP代替,这个机器的IP不是服务器的IP,而是安装或者启动XWindow的客户端的机器的IP。
如果你安装的时候用的是远程的xwindows的客户端的话,这个IP会自动配置为你当时登录客户端机器的IP,如果你后来配置report时
更换了机器,也需要注意更改这个IP.

Metalink里面的一篇文章,给转帖过来了

PURPOSE
========
The purpose of this document is to:
	- provide information on how to resolve the REP-3000 error. 
	- explain why the DISPLAY environment variable is required when 
          running Reports on UNIX machines. 
	- describe the history behind this problem.
	- give hints on how to troubleshoot problem.
	- include a comprehensive summary of various scenarios which may
	  result in a REP-3000 error.

SCOPE & APPLICATION
====================
Intended Audience:  Developers, System Administrators, Consultants

Most of the information in this note is based on Oracle Reports 6i, but 
there will be some version-specific items included, i.e. Reports 9i, 
Reports 2.5.x, even though some of the versions are no longer supported.  
Bear in mind that support for Reports versions prior to Reports 6i (6.0.8.x) 
is limited to known issues and migration.

This note is broken up in the following sections:

 I.   PROBLEM DESCRIPTION 
 II.  SOLUTION 
 III. EXPLANATION
 IV.  HISTORY
 V.   TROUBLESHOOTING:
 VI.  SCENARIOS WHERE YOU MAY ENCOUNTER REP-3000 
	1. Reports Version-Specific Issues
	2. Oracle Forms Related Issues
	3. Oracle Applications Related Issues
	4. NLS_LANG Related Issues
	5. OC4J Issues
	6. General Issues


I. PROBLEM DESCRIPTION 
=======================
Running a report using Reports Runtime (rwrun60), using Reports Builder 
(rwbld60), using Reports Server Client (rwcli60), accessed over the Web 
(rwcgi or rwservlet), or called from Oracle Forms results in the following error:

REP-3000: INTERNAL ERROR STARTING ORACLE TOOLKIT


 
II. SOLUTION 
============
You must set the DISPLAY environment variable to a valid X Windows session. 

If you are running report using rwrun60, you need to set DISPLAY in the same 
session that you invoke rwrun60.  If you are running report through the 
Reports Server (Services) using rwcli60 or on the web, then you need to 
ensure that the Reports Server (Services) is started from the session that 
has a valid DISPLAY environment variable.

Syntax to set the DISPLAY environment variable:

C Shell
---------
% setenv DISPLAY <hostname>:0.0  

Bourne or Korn Shell
--------------------------
$ DISPLAY=<hostname>:0.0;export DISPLAY

NOTE: you may use <ip_address>:0.0 instead of <hostname>:0.0. 

You have 2 options to enable your Reports Server (Services).

Option 1
---------
You will need to setup the DISPLAY environment variable to point to an active 
X Windows.  This means:
   1. reconfiguring your Unix server to have an active xterm session.
   2. using the IP Address of your PC with X-emulation, e.g. Exceed or X-Reflection.
      Please note that the use of PC based X-emulation is not supported. See Note 2056834.6.
   3. finding a Windows printer server that is always up and use its IP Address.

   In cases 2 & 3, you do not have to be connected to the server, just have the 
   PC running and available on the network. 

Option 2
---------
If you do not want to run a full-blown X-Windows, then you may use the 
freeware X server VNC.

Information on how to use VNC is included in:

section 1.5.7.1.6 in the iAS 1.0.2.2 release notes (Note 146652.1)
or section 12.22 in the iAS 1.0.2.1 release notes (Note 139837.1)


III. EXPLANATION
===============
In order to run bitmapped reports, the engines spawned by the Oracle 
Reports Server (Services) need to have access to an appropriate 
windowing system. On Windows platforms this is a non-issue, but on 
non-Windows platforms this means that a valid X Windows session must 
be available. 

If the DISPLAY environment is not set correctly for the Reports Server 
on UNIX platforms, issuing any command to run a report results in the 
REP-3000 error.

IV. HISTORY
===========
Setting the DISPLAY to a valid X Windows session is a REQUIREMENT 
and has always been a requirement. It is NOT a bug. It provides a 
fundamental capability that Reports requires for font metrics and 
rasterization, image manipulation and conversion, etc. This is not 
just specific to Oracle Reports. All UNIX-based machines require an 
X-Windows and Motif environment to run any GUI-based product.  A 
long time ago, there was a special character mode executable that 
did not require X Windows when doing only character mode reports.  
However, this is no longer the case.

V. TROUBLESHOOTING
===================
Take the following steps to help you troubleshoot REP-3000 errors:

  1.  First, test the integrity of DISPLAY by issuing "xclock" command.  
	 - Login to the machine where Reports Server is installed.  
	 - From the UNIX command prompt, set the DISPLAY to a valid 
           X Windows session:
	     setenv DISPLAY <hostname>:0.0
	 - Ensure that DISPLAY was set correctly:
	     echo $DISPLAY
	 - Type command "xclock"
    If you see a clock come up, then the DISPLAY is set correctly.  
    If you do not see the clock, then DISPLAY is not set to an active Xterm. 

    You must have xclock working before running any reports.
  
    Another way to test whether an X server is running on given machine
    and you have permissions to connect to it, you can use the following command: 

    xterm -display <hostname>:0.0

    If you do not have permissions to access the display or if there is no 
    such display running on the given machine, an error similar to the 
    following is displayed: 

    Xlib: connection to "<hostname>:0.0" refused by server
    Xlib: Client is not authorized to connect to Server
    xterm Xt error: Can't open display: <hostname>:0.0


  2.  If the error occurs when running report on the Web, then you need 
    to first test it using Reports Runtime on the machine where your Reports 
    Server is running.  Steps:
	 - Set DISPLAY to a valid X Windows session
	 - Run report using sample syntax:
    rwrun60 report=test.rdf userid=username/password@db destype=file desname=test.html desformat=html batch=yes

    If rwrun60 works, go to step 3.
    If rwrun60 does not work, then:
	- Re-check your DISPLAY environment variable 
	- Go back to step 1 and test the integrity of DISPLAY
	- Review Section VI (below) to see if any of the scenarios 
          match your situation.
	- If nothing else works, then try to relink Oracle Reports executables.  
          See Note 154512.1 for details.

  3. Test it using rwcli60.  Steps:
	- Set DISPLAY to valid X Windows either in the reports60_server 
          startup script, or in reports60.sh (if you are manually starting 
          up the reports server using rwmts60)
        - Restart the reports server with this DISPLAY set
	- Run report using sample syntax:
    rwcli60 server=repserver.world  report=test.rdf userid=username/password@db destype=file desname=test.html desformat=html batch=yes

   where repserver.world is the name of your reports server services.

    If rwcli60 works, go to step 4.
    If rwcli60 does not work, then:
	- Check the DISPLAY setting in the script that you used to start 
          up the reports server.  Most likely, you used the reports60_server 
          script which is located in Reports 6i Oracle_Home.  
	- Review Section 6 (below) to see if any of the scenarios match 
          your situation. 

  4.  If rwrun60 and rwcli60 work, then the problem is in the CGI or Servlet 
    setup, and not the Reports Server Services.  

    For CGI setup, the DISPLAY needs to be set in the CGI shell script, and/or 
    the 6iserver.conf file. This is found under the Reports 6i Oracle_Home in 
    the conf directory (e.g. /u01/app/oracle/product/ias/6iserver/conf)

    Edit the 6iserver.conf to read:
    .
    # Forms and Reports CGI needs to have ORACLE_HOME set
    SetEnvIf Request_URI  "rwcgi60"   ORACLE_HOME=/u05/app/oracle/product/iAS9i/6iserver
    SetEnvIf Request_URI  "rwcgi60"   DISPLAY=<hostname>:0.0

    For the Servlet setup, you need to set DISPLAY in the jserv.properties file. 
    For details, see Note 162453.1.

VI. SCENARIOS WHERE YOU MAY ENCOUNTER REP-3000 
==============================================
There are numerous situations where you may encounter the REP-3000 error.  
The different scenarios as well as their resolutions are listed below.  
These are grouped in the following categories:

   1. Reports Version-Specific Issues
   2. Oracle Forms Related Issues
   3. Oracle Applications Related Issues
   4. NLS_LANG Related Issues
   5. General Issues

VI-1. REPORTS VERSION-SPECIFIC ISSUES:
------------------------------------

A)  REPORTS 6i PATCH5 or HIGHER:  Reports No Longer Work After Patch5

   Description:
   After applying Reports 6i patch 5 or higher, running reports in batch no 
   longer works.  Gives error:
 
     REP-3000: Internal error starting Oracle Toolkit 

   Why can't the server work anymore without a console/Xwindows setup like 
   it did before?

   Solution:
   See Section II above. ("Solution").

   Explanation:
   In patch 5, development addressed several bugs regarding image display and 
   resolution.  One of the things to come out of this was that we needed to 
   enforce the requirement for a valid display being set.  We have always said 
   that you needed to have the DISPLAY environment variable set to a valid X 
   Display on non-Windows platforms. It provides a fundamental capability that 
   Reports requires for font metrics and rasterization, image manipulation and 
   conversion, etc.

   Essentially, you have been relying on a behavior that was against the 
   documentation.  

   Also, to help the graphics/reports integration work better, the software 
   now accesses the OS to pull Pixel information from the windowing system.  
   In the past this was hardcoded into the software and it could cause a 
   problem when images were run on different resolutions. We have found that 
   in some cases this Pixel check has been the cause of the REP-3000.  You can 
   get around this by setting an environment variable that overrides the OS 
   windowing check.  In the reports60_server script add the line:

   REPORTS60_DEFAULT_PIXEL_SIZE=80; export REPORTS60_DEFAULT_PIXEL_SIZE

   WARNING: Setting this parameter also overrides the fixes that Patch 5 
   incorporated for proper report/graphics integration.  Note this is not 
   recommended.  You may experience graphic degradation if this is set.

B)  REPORTS 9i:   Running Report on Web in 9iAS V2 Environment

   Description:
   You have successfully installed 9iAS V2 on your Unix machine.  When 
   attempting to run a report through a URL you get the following error:

   "Oracle Reports Server CGI - Report Job has terminated with error.
   Reports Server Replies: 
   REP-3000: Internal error starting Oracle Toolkit."

   Solution:
   To ensure that the DISPLAY environment variable is set correctly in a 9iAS V2 
   environment, or any environment where a Reports9i server is being used, you 
   have to add an entry referencing this variable in the reports.sh script.  
   This file is found in the ORACLE_HOME/bin directory.

   Explanation:
   The reports.sh script is accessed every time that a Reports9i Server engine 
   is started.  By setting the correct value for DISPLAY in this file, and 
   restarting the appropriate OC4J instance, you ensure that every new server 
   engine will be accessing the correct information concerning this variable.  

C)  REPORTS 9i/10g:  Reports in-process server gives REP-3000 error when running report 

   Description:
   When running a sample report using the Reports in-process server, the
   following error message appears in the browser: 

   REP-3000: Internal error starting Oracle Toolkit.

   Solution:
   Ensure that the DISPLAY environment variable is set correctly in the 
   following configuration file:

   9i:
   $ORACLE_HOME/j2ee/OC4J_BI_Forms/config/oc4j.properties
   10g:
   $ORACLE_HOME/opmn/conf/opmn.xml 

   The default DISPLAY entry is as follows: 
   9i:
   oracle.display=:0.0
   10g:
   <variable id="DISPLAY" value="localhost:0"/>

   You need to change the default entry to a machine with a valid X server. 
   For example, to use the X server running on myserver:0.0, you would change 
   the default entry to: 
   9i:
   oracle.display=myserver:0.0 
   10g:
   <variable id="DISPLAY" value="myserver:0.0"/>

   After these changes are completed, it is necessary to restart the 
   Forms/Reports OC4J instance.  You can either restart this using
   Enterprise Manager, or from the command line using the following commands: 

   $ cd $ORACLE_HOME/opmn/bin
   $ ./opmnctl stopproc type=oc4j instancename=oc4j_bi_forms
   $ ./opmnctl startproc type=oc4j instancename=oc4j_bi_forms

   Explanation:
   When running a Reports Server from the command line, the environment 
   variable DISPLAY setting is used. However, the Reports in-process server 
   uses the oc4j.properties or opmn.xml configuration file for the display 
   setting.

D)  ORACLE REPORTS 6.0.5.X:  REP-3000 Error Running rwrun60c

   Description:
   Running a report using rwrun60c fails with the following errors:

   REP-3000: Internal error starting Oracle Toolkit.
   REP-0548 Problem Initializing Oracle Toolkit. 

   Solution:
   Apply patch 5a for Developer 6.0
   or
   Use Developer 6i with Patch 1 or higher
   or 
   Use Workaround:
     1. Set TERM=vt100
     2. Unset ORACLE_TERM 

   Explanation:
   You have encountered a known bug:
   Bug 771022 TOOLKIT ERROR WHEN LAUNCH RUNTIME (RWRUN60C) 

E)  ORACLE DEVELOPER 1.6.1:  Running Report in 1.6.1 Environment

   Description:
   You have set your DISPLAY correctly and the "xclock" product runs without 
   any problems.  You can open an XTERM successfully and can run other motif 
   and x-windows programs successfully from the server.  However, you still 
   receive the REP-3000 error when running r25runm or any Reports executable 
   in an Oracle Developer 1.6.1 environment.

   Solution:
   Set ORA_NLS33 environment variable to:

   ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/datad2k

   Explanation:
   Oracle Developer 1.6.1requires ORA_NLS33 to be set for the Reports 2.5 and 
   Forms 4.5 motif products to run. Other versions of Developer do not need 
   this variable.  This will point the NLS to the correct nlb files. The 
   ORA_NLS33 is defaulting to $ORACLE_HOME/ocommon/nls/admin/data and picking 
   up the wrong file.

F)  REPORTS 2.5.X:  Running Report Using r25runm Batch=Yes On VMS

   Description:
   You are getting REP-03000 when using R25RUN batch=yes on VMS.

   Solution:
   Setting mode=character gets rid of the error.

VI-2. ORACLE FORMS RELATED ISSUES:
---------------------------------

A)  REP-3000 Using RUN_REPORT_OBJECT After Installing Patch 5

   Description:
   You are using Reports inside Forms, started with RUN_REPORT_OBJECT (without 
   REPORT_SERVER specified) or RUN_PRODUCT with batch=yes.  After applying 
   Developer 6i patch 5 or higher, you get the REP-3000 error when you run 
   reports.  This worked fine before installing Patch 5.

   Solution:
   Set the DISPLAY variable to a valid Xwindows before starting the report 
   or the Forms listener.

   If you are running Webforms with Forms servlet listener, you have to set 
   the variable in the jserv.properties file.

   $ORACLE_HOME/Apache/Jserv/etc/jserv.properties

   wrapper.env=DISPLAY=<hostname>:0.0

   You have to restart your apache listener afterwards.

   Explanation:
   See Section IV-1.A above.


B)  REP-3000 Running Forms 4.5.x Executable On MOTIF

   Description:
   You have set your DISPLAY correctly and the "xclock" product runs without 
   any problems.  You can open an XTERM successfully and can run other motif 
   and X-Windows programs successfully from the server.  However, when run 
   f45runm or any Forms executable in an Oracle Developer 1.6.1 environment, 
   you receive one or more of  the following errors:

     FRM-91111: Internal Error: window system startup failure. 
     FRM-10039: Unable to start up the Forms Designer. 
     REP-03000: Internal error starting Oracle Toolkit.

   Solution:
   Set ORA_NLS33 environment variable to:

   ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/datad2k

   Explanation:
   See Section VI-1.D above.


VI-3. ORACLE APPLICATIONS RELATED ISSUES:
-----------------------------------------

A)  Running Applications 11i Reports Result in REP-3000

   Description:
   Using Oracle Applications Release 11i and Reports Server 6i, any report 
   run from Applications results in a REP-3000 error.

   Solution:
   Set DISPLAY to a valid Xwindows in the shell scripts that set up your Apps 
   environment.  Set it in the following:
      - reports60.csh
      - reports60.sh
      - reports60_server
      - adrepctl.sh (starts the repserver)
      - adcmctl.sh (concurrent manager script)
      - all 3 ENV files that reside under APPL_TOP:
	   <SID>.env (controls application-environmental script of applmgr)
           APPSORA.env (setups up ORACLE_HOME and all the other XX_TOPs.)
   	   APPLSYS.env (defines all the top-level directories and NLS env variables)

   Then restart your reports server after modifying these scripts.

   If this does not work, then check your NLS_LANG setting in all of 
   the above scripts.  Try setting NLS_LANG to AMERICAN_AMERICA.WE8ISO8859P1.   
   For more info, see Section 6.IV.A.

   Explanation:
   Resolving issue is a matter of setting DISPLAY in the appropriate script.  


VI-4. NLS_LANG RELATED ISSUES:
-----------------------------  

A)  REP-3000 When NLS_LANG Is Set to NON Western European Character

   Description:
   Encounter REP-3000 when the Reports server NLS_LANG is set to any Language, 
   like AMERICAN_AMERICA.ZHT16BIG5, other than AMERICAN_AMERICA.WE8ISO8859P1.

   Solution:
   If NLS_LANG is set to AMERICAN_AMERICA.ZHT16BIG5, then set the
   TK60_UNKNOWN or ORACLE_UNKNOWN environment variable to:

   TK60_UNKNOWN=$ORACLE_HOME/guicommon6/tk60/admin/ZHT 

   Explanation:
   By default, when the <LANGUAGE>_<TERRITORY> in NLS_LANG is AMERICAN_AMERICA,
   the Reports server looks for the Tk2Motif.rgb in $ORACLE_HOME/guicommon6/tk60/admin
   directory.  However, for non-western European character sets, the corresponding
   Tk2Motif.rgb files reside in individual folders under $ORACLE_HOME/guicommon6/tk60/admin.  
   For example:

   ZHT16BIG5:   Tk2Motif.rgb is in $ORACLE_HOME/guicommon6/tk60/admin/ZHT folder.
   ZHS16CGB231280:  Tk2Motif.rgb is in $ORACLE_HOME/guicommon6/tk60/admin/ZHS folder.

   If <LANGUAGE>_<TERRITORY> in NLS_LANG matches the <CHARSET> then there is no 
   need to set TK60_UNKNOWN.

   For example, if NLS_LANG is set to "TRADITIONAL CHINESE"_TAIWAN.ZHT16BIG5,
   then Reports server  automatically goes to $ORACLE_HOME/guicommon6/tk60/admin/ZHT
   directory to find the correct Tk2Motif.rgb and TK60_UNKNOWN need not be set 
   in this case.

B)  REP-0069, REP-57054 and REP-3000 errors if NLS_LANG is set to UTF8 in UNIX.
 
   Description:
   Encounter the following errors when running a report to PDF in UNIX, 
   when NLS_LANG is set to AMERICAN_AMERICA.UTF8.

      REP-0069: Internal error
      REP-57054: In-process job terminated: Terminated with error: 
      and/or
      REP-3000: Internal error starting Oracle Toolkit.
      SIGSEGV   11*  segmentation violation

   Solution:
   1. Edit the file Tk2Motif.rgb located at <Mid-tierHOME>/guicommon9/tk90/admin
   2. There, you can find this line which is commented:
     !Tk2Motif*fontMapCs: iso8859-2=EE8ISO8859P2
   3. Add a line below this as :
     Tk2Motif*fontMapCs: iso8859-1=UTF8

   Explanation:
   See explanation from Issue A above.

C) REP-3000 with NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

   Description:
   Error REP-3000 occurs when starting rwrun60 with NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
   After setting NLS_LANG=AMERICAN_AMERICA.US7ASCII, the error is gone. 
   After setting NLS_LANG=AMERICAN_AMERICA.UTF8, rwrun60 runs OK, too. 
   Unsetting NLS_LANG altogether works just fine, too. 

   Solution:
   Restore Tk2Motif.rgb - comment out as follows: 
   change 
   Tk2Motif*fontMapCs: iso8859-1=UTF8 
   into 
   !Tk2Motif*fontMapCs: iso8859-1=UTF8    
   
   Explanation:
   Tk2Motif.rgb had been modified, the following line was inserted: 
   Tk2Motif*fontMapCs: iso8859-1=UTF8 
   This means reports expects UTF8 ... 


VI-5. OC4J ISSUES:
------------------- 

A) REP-3000 Error when Running Rerport on Web Before Running OC4J Demo. 
   
   Description:
   REP-3000 Oracle toolkit error when the report is run through rwservlet. 
   The error doesn't occur if the OC4J DEMO is run before running the report.

   Solution:
   In order to overcome this problem set the DISPLAY to :0.0.

   Explanation:
   The reason why the report after running OC4J_DEMO is as follows.
   When OC4J_DEMO is run it would use the "OC4J_DEMO.properties" file which 
   has the property "oracle.display=:0.0". This would set the display to the 
   server. If the report is run after running OC4J_DEMO you wouldn't get any 
   errors as the display is already set.


VI-6. GENERAL ISSUES:
------------------- 

A)  REP-3000 When Trying to Convert a Report

   Description:
   You are receiving REP-3000 when trying to convert an .RDF report using the convert tool.  E.g. 
   rwcon60 (Reports 6.0.x) or r25convm (Reports 2.5.x) or r25mrepm (Reports 2.5.x), etc

   Solution:
   You must do one or both of the following:
      - Set DISPLAY to valid X Windows 
      - Pass batch=yes on the command line if you don't have motif installed 
        on Unix 

B)  REP-3000 / "XLIB: CONNECTION TO <IP ADDRESS> REFUSED BY SERVER" When Running Reports

   Description:
   When running reports over the WEB generating HTML, you get REP-3000 error 
   in the browser, and on the server you see: 

        Xlib:connecion to <IP address> refused by the server
        Xlib:invalid MIT-magic-cookie key...

   Solution:
   If you are logged on machine A and want to display the output to machine B, 
   try:
 
        a. on machine A, type 'setenv DISPLAY B:0.0'  
        b. on machine B, type 'xhost +'
        c. start your program on machine A
 
   In this case, set the DISPLAY environment variable on the server where 
   you have installed the Reports Server and then issue the 'xhost +' command.

   If you perform 'xhost +' you need to be logged in as 'root' and you need
   to telnet directly to the server.

   Explanation:
   You have embedded graphics in your report and only when generating HTML 
   you get the errors. You have set the DISPLAY environment variable; however, 
   Reports cannot access the display screen.
         
C)  Starting Reports Server In Conjunction With VNC Server Fails

   Description:
   Starting Reports Server in conjunction with VNC server fails with errors:
        REP-3000: Internal error starting Oracle Toolkit.
        Xlib: connection to "s0006mq2:13.0" refused by server
        Xlib: Invalid MIT-MAGIC-COOKIE-1 key

   Solution:
   Drop .Xauthority and re-start Reports Server.

   Explanation:
   The file .Xauthority in the home directory of the VNC user is corrupt.

D)  REP-3000 on Linux RedHat 7.1 after all the above has been accomplished

   Description:
   Starting Reports Server with PC or VNC server fails with errors:
        REP-3000: Internal error starting Oracle Toolkit.

   Solution:
   The package that is the problem is openmotif-2.2.2-3_ICS	
   Please make sure that you have installed  Motif 2.1.
     Motif: Open Motif 2.1.30
     Runtime libraries and executables version 2.1.30-4_MLI.hi

   Open Motif 1.2 or 2.2 are not certified with 6i.

   You can download the latest Open Motif 2.1 binary or source packages from 
   the Metro Link Web site at: 
   http://www.metrolink.com/openmotif/

   Metro Link's Open Motif binary packages are also available directly from 
   the Open Group's official Open Motif Web site at: 
   http://www.opengroup.org/openmotif/
   
   Explanation:
   Only Open Motif 2.1 is tested/certified with Reports 6i.

E) Rep-3000 even with DISPLAY pointing to XVFB process

   Description:
   Starting Reports Server with DISPLAY is pointing to the XVFB process running
   fails with errors:
        REP-3000: Internal error starting Oracle Toolkit.

   Solution:
   Create a script with the following commands so that they are executed by 
   root user at startup.

   For SUN-SOLARIS 8
   ---------------
   /usr/X11R6/bin/Xvfb :1 -ac -screen 0  1024x768x8 &
   DISPLAY=<server_name>:1.0;export DISPLAY
   /usr/X/bin/olwm  &
   xhost +

   
   For SUN-SOLARIS 9
   ---------------
   /usr/openwin/bin/Xvfb :1 -screen 0 1152x900x8 &
   DISPLAY=<server_name>:1.0;export DISPLAY
   /usr/openwin/bin/twm &
   xhost +


   For HP-UX and TRU64
   --------------------
   /usr/bin/X11/Xvfb :1 -ac -screen 0  1024x768x8 &
   DISPLAY=<server_name>:1.0;export DISPLAY
   /usr/bin/X11/mwm   &
   xhost +


   For AIX
   -------
   Use
   /usr/bin/X11/xinit -- -force -vfb -x abx -x dbe -x GLX :1  
   instead of the following:     
   /usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :1   

   DISPLAY=<server_name>:1.0;export DISPLAY
   xhost +

   For AIX release 5.0 and 5.1, the syntax should be:
   /usr/bin/X11/xinit -- :1 -force -vfb -x abx -x dbe -x GLX
   Note that the :1 is in a different position.

   For AIX version 5.2 and higher, the syntax to load xvfb and windows manager is:
   /usr/lpp/X11/bin/xinit /usr/lpp/X11/bin/mwm -- :1 -vfb -force -x abx -x dbe   -x GLX &
          

   For Linux
   ---------
   Linux requires that mwm be started first
   /usr/X11R6/bin/mwm &
   /usr/X11R6/bin/Xvfb :1 -ac -screen 0  1024x768x8 &
   DISPLAY=<server_name>:1.0; export DISPLAY
   xhost +


   Explanation:
   Olwm and mwm are window managers for the X Window System that implements 
   parts of the OPEN LOOK graphical user interface. They are standard products 
   and come built in with Sun Solaris and HP-UX installations respectively.

   The "X" command for AIX (second command) creates a vfb that does not include
   a Motif Window Manager (MWM) whereas the vfb created using "xinit" does have
   the MWM. 

   If using XVFB, Oracle Reports somehow needs that the Window Manager be 
   started with automatic display placement. 

F) REP-3000 on Linux when try to execute Runtime, Builder or Reports Server

   Description:
   Get error REP-3000 on Linux platform when trying to start rwbld60 
   and rwrun60, and running reports using Reports Server.

   Solution:
   1) Switch to the KDE environment, not just a plain X window session.
   2) Add /opt/kde2/lib to the LD_LIBRARY_PATH.

   Explanation:
   This is an issue of incompatibility between Motif 2.1 and the Gnome 
   Desktop Manager on Linux. The workaround is to use KDE instead of Gnome.
   Reference:
   Bug 1416449  REP-3000:INTERNAL ERROR STARTING ORACLE TOOLKIT WHEN REPORT STARTED ON REDHAT6.0
   Note 136678.1  Shared Libs Missing Sarting Motif Executables on SuSE Linux with Gnome 

G) Rep-3000 with DISPLAY pointing to Xsun process

   Description:
   Starting Reports Server with DISPLAY pointing to the Xsun process running
   fails with error:
        REP-3000: Internal error starting Oracle Toolkit.

   Solution:
   
   Need to also start up the window manager dtwm when starting up Xsun.
   The following is a sample script this is executed by root user at startup.

   1. Start up Xsun using following script (which includes windows manager dtwm):

     root># more /etc/init.d/dtlogin
     #!/bin/sh
     #
     case "$mode" in

     'start')
        /usr/openwin/bin/xinit /usr/dt/bin/Xsession  -- /usr/openwin/bin/X -nobanner >>/var/dt/Xerrors 2>&1
        ;;

     'stop')
        ;;

     *)
        exit 1
        ;;
     esac
     exit 0

   2. Check to be sure it started:
    root># ps -ef |grep Xs
    root  7254  7252  0 14:58:03 pts/1    0:00 /bin/ksh /usr/dt/bin/Xsession
    root  7252  7237  0 14:58:02 pts/1    0:00 /usr/openwin/bin/xinit /usr/dt/bin/Xsession -- /usr/openwin/bin/X -nobanner
    root  8427  6712  0 15:27:06 pts/5    0:00 grep Xs
 
    root># ps -edf| grep wm
    root  7333  7331  0 14:58:07 ?        0:01 dtwm
    root  8470  6712  0 15:28:35 pts/5    0:00 grep wm

   3. As root, set DISPLAY accordingly:
     DISPLAY="0:0";export DISPLAY
  
    Check to ensure it's set:
    root># echo $DISPLAY
         0:0

   4. Execute xhost +


   Explanation:
   Like XVFB, Xsun needs to have the window manager started in order for 
   Reports to work. The dtwm is the window manager for the X Window System 
   that implements parts of the OPEN LOOK graphical user interface. 
   It is a standard product and comes built in with Sun Solaris.

H) Rep-3000 with DISPLAY pointing to vncserver on AIX

   Description:
   Reports server runs when DISPLAY set to remote Xwindows process.
   After vncserver is installed and started, the reports server will fail with
   REP-3000.
  
   The cause is that the $HOME/.vnc/xstartup script has conflicts with the 
   vncserver on this platform.

   Solution:
   To implement the solution, please execute the following steps:

   1. Edit the $HOME/.vnc/xstartup

   A) Comment line:
   FROM 
   /usr/dt/bin/dtwm &
   TO
   #/usr/dt/bin/dtwm &

   B) Comment line:
   FROM
   #mwm &
   TO
   mwm &

   NOTE: The actual process required for each AIX server may vary.

SAP abap程序名称report znmmr037. report znmmr037. include znmmx037ta. include znmmx037sa.include znmmx037fa.INITIALIZATION. MOVE '@2L@ Download the Excel template' TO BTN. AT SELECTION-SCREEN ON VALUE-REQUEST FOR GV_FILE. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING DEF_FILENAME = '*.*' DEF_PATH = GV_FILE MASK = ',*.*.' MODE = 'O' TITLE = 'Choose input file' IMPORTING FILENAME = GV_FILE EXCEPTIONS INV_WINSYS = 1 NO_BATCH = 2 SELECTION_CANCEL = 3 SELECTION_ERROR = 4 OTHERS = 5. AT SELECTION-SCREEN. CASE sy-ucomm. WHEN 'BTN1'. PERFORM FRM_DOWN_TEMPLATE. ENDCASE. *END ADD AT SELECTION-SCREEN OUTPUT . PERFORM FRM_MOD_SCREEN. start-of-selection. *modify by songjiaru 20200516 IF R1 = 'X'. PERFORM FRM_MAINTAIN_EMAIL."邮箱维护 ENDIF. IF R2 = 'X'. PERFORM FRM_QUERY. ENDIF. IF R3 = 'X'. PERFORM frm_check. perform frm_get_data. perform frm_output_data. ENDIF.*&---------------------------------------------------------------------* *& 包含 ZNMMX037TA *&---------------------------------------------------------------------* TABLES:NAST,EKKO,ZNMMT037. * MODIFY BY SONGJIARU 20200516 TABLES : LFA1 ,EKPO . *END MODFIY DATA:GS_LAYOUT TYPE LVC_S_LAYO, GS_FCAT TYPE LVC_S_FCAT, GT_FCAT TYPE LVC_T_FCAT. DATA:BEGIN OF GS_DATA, LIFNR LIKE EKKO-LIFNR, EBELN LIKE EKKO-EBELN, EKORG LIKE EKKO-EKORG, EKGRP LIKE EKKO-EKGRP, WERKS LIKE EKPO-WERKS, BEDAT LIKE EKKO-BEDAT, BUKRS LIKE EKKO-BUKRS, NAME1 LIKE LFA1-NAME1, MCOD1 LIKE LFA1-MCOD1, ADRNR LIKE LFA1-ADRNR, SPRAS LIKE NAST-SPRAS, SMTP_ADDR LIKE ADR6-SMTP_ADDR, BOX TYPE C, ICON TYPE ICON-NAME, MESSAGE TYPE C LENGTH 120, ERDAT TYPE ZNMMT037-ERDAT, *add by songjiaru 20200519 FLAG TYPE C, *end add END OF GS_DATA. DATA:GT_DATA LIKE GS_DATA OCCURS 0, GS_DATA2 LIKE LINE OF GT_DATA. DATA:BEGIN OF GS_MAIL, ADRNR LIKE LFA1-ADRNR, SMTP_ADDR LIKE ADR6-SMTP_ADDR, END OF GS_MAIL. DATA:GT_MAIL LIKE GS_MAIL OCCURS 0. *ADD BY SONGJIARU 20200516 DATA: V_EXCEL TYPE OLE2_OBJECT, V_SHEET TYPE OLE2_OBJECT, V_BOOK TYPE OLE2_OBJECT, V_CELL TYPE OLE2_OBJECT, V_RANGE TYPE OLE2_OBJECT, V_FONT TYPE OLE2_OBJECT, V_COLOR TYPE OLE2_OBJECT, V_COLUMN TYPE OLE2_OBJECT, BORDERS TYPE OLE2_OBJECT. DATA : BEGIN OF GS_ITEM , LIFNR LIKE LFA1-LIFNR, EKORG LIKE EKKO-EKORG, WERKS LIKE EKPO-WERKS, EKGRP LIKE EKKO-EKGRP, EMAIL LIKE ADR6-SMTP_ADDR, END OF GS_ITEM. DATA : GT_ITEM LIKE TABLE OF GS_ITEM. DATA : BEGIN OF GS_LFA1, LIFNR LIKE LFA1-LIFNR, NAME1 LIKE LFA1-NAME1, END OF GS_LFA1. DATA : GT_LFA1 LIKE TABLE OF GS_LFA1. DATA : BEGIN OF GS_EMAIL_ALV, LIFNR LIKE LFA1-LIFNR, NAME1 LIKE LFA1-NAME1, EKORG LIKE EKKO-EKORG, WERKS LIKE EKPO-WERKS, EMAIL LIKE ADR6-SMTP_ADDR, UNAME TYPE STRING, MESSAGE TYPE STRING, END OF GS_EMAIL_ALV. DATA : GT_EMAIL_ALV LIKE TABLE OF GS_EMAIL_ALV. DATA:GT_ALSM TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE. FIELD-SYMBOLS:<GFS_DATA> TYPE ANY. DATA : GT_ZNMMT037A TYPE TABLE OF ZNMMT037A. DATA : GS_ZNMMT037A LIKE LINE OF GT_ZNMMT037A. DATA BEGIN OF GS_QUERY_ALV. INCLUDE TYPE ZNMMT037A. DATA : BOX TYPE C. DATA END OF GS_QUERY_ALV. DATA : GT_QUERY_ALV LIKE TABLE OF GS_QUERY_ALV. TYPES BEGIN OF GS_STRUCTURE . INCLUDE STRUCTURE GS_ZNMMT037A. TYPES FLAG TYPE C. TYPES END OF GS_STRUCTURE. DATA : GS_MESSAGE TYPE GS_STRUCTURE. DATA : GT_MESSAGE LIKE TABLE OF GS_MESSAGE. DEFINE GMRC_INITIAL_FIELD. "定义宏 GS_FIELDCAT-SELTEXT_L = &1. GS_FIELDCAT-SELTEXT_M = &1. GS_FIELDCAT-SELTEXT_S = &1. GS_FIELDCAT-FIELDNAME = &2. GS_FIELDCAT-FIX_COLUMN = &3. APPEND GS_FIELDCAT TO GT_FIELDCAT. END-OF-DEFINITION. DATA : GS_LAYOUT1 TYPE SLIS_LAYOUT_ALV, GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, GS_FIELDCAT LIKE LINE OF GT_FIELDCAT. DATA : GT_EVENTS TYPE SLIS_T_EVENT, GS_EVENTS TYPE SLIS_ALV_EVENT. DATA : BEGIN OF GS_WERKS, WERKS LIKE T001L-WERKS, FLAG TYPE C, END OF GS_WERKS. DATA : GT_WERKS LIKE TABLE OF GS_WERKS. data:begin of gt_detailtab2 occurs 0, info(999) type c, end of gt_detailtab2. data:lv_content_text type string. *END ADD&---------------------------------------------------------------------* *& 包含 ZNMMX037SA *&---------------------------------------------------------------------* *selection-screen begin of block bl1 with frame title text-001. *MODIFY BY SONGJIARU 20200516 PARAMETERS : R1 RADIOBUTTON GROUP G1 USER-COMMAND G1. PARAMETERS:GV_FILE LIKE RLGRAP-FILENAME MODIF ID M1 MEMORY ID PID. SELECTION-SCREEN PUSHBUTTON /35(45) BTN USER-COMMAND BTN1 MODIF ID M1. PARAMETERS : R2 RADIOBUTTON GROUP G1 . SELECT-OPTIONS : S_LIFNR1 FOR LFA1-LIFNR MODIF ID M2. SELECT-OPTIONS : S_EKORG1 FOR EKKO-EKORG MODIF ID M2. SELECT-OPTIONS : S_EKGRP1 FOR EKKO-EKGRP MODIF ID M2. SELECT-OPTIONS : S_WERKS FOR EKPO-WERKS MODIF ID M2. PARAMETERS : R3 RADIOBUTTON GROUP G1 DEFAULT 'X'. select-options:s_ebeln for ekko-ebeln MODIF ID M3, s_lifnr for ekko-lifnr MODIF ID M3, s_ekorg for ekko-ekorg MODIF ID M3, s_ekgrp for ekko-ekgrp MODIF ID M3, s_werks1 for ekpo-werks MODIF ID M3, s_bsart for ekko-bsart MODIF ID M3, s_bedat for ekko-bedat MODIF ID M3, s_spras for nast-spras MODIF ID M3. *END MODIFY *selection-screen end of block bl1. PARAMETERS:ck_wfs as CHECKBOX, c_multi as CHECKBOX. "多附件发送 *&---------------------------------------------------------------------* *& 包含 ZNMMX037FA *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_GET_DATA . *modify by songjiaru 20200519 SQL 性能优化 及 更改收件人邮箱取数逻辑 这里默认的是一个PO 只会存在一个工厂的数据 *不然没办法按照采购部的供应商+采购组织+工厂取ZNMMT037A来取数了 SELECT EKKO~EBELN , EKKO~BEDAT , EKKO~EKGRP , EKKO~LIFNR , EKKO~BUKRS , NAST~SPRAS , EKKO~EKORG , EKPO~WERKS INTO CORRESPONDING FIELDS OF TABLE @GT_DATA FROM EKKO INNER JOIN EKPO ON EKKO~EBELN = EKPO~EBELN JOIN NAST ON NAST~OBJKY = EKKO~EBELN WHERE EKKO~EBELN IN @S_EBELN AND EKKO~LIFNR IN @S_LIFNR AND EKKO~EKORG IN @S_EKORG AND EKKO~EKGRP IN @S_EKGRP AND EKKO~BSART IN @S_BSART AND EKKO~BEDAT IN @S_BEDAT AND EKPO~WERKS IN @S_WERKS1 AND EKKO~FRGKE = '7' AND NAST~SPRAS IN @S_SPRAS. SORT GT_DATA BY EBELN. DELETE ADJACENT DUPLICATES FROM GT_DATA COMPARING EBELN. * LOOP AT GT_DATA INTO GS_DATA . * SELECT SINGLE * FROM ZNMMT037 * WHERE EBELN = GS_DATA-EBELN. * IF SY-SUBRC = 0. * IF CK_WFS = 'X'. * DELETE GT_DATA. * CONTINUE. * ENDIF. * GS_DATA-ICON = '@08@'. * GS_DATA-MESSAGE = '已有发送记录'. * GS_DATA-ERDAT = ZNMMT037-ERDAT. * ENDIF. * * SELECT SINGLE NAME1 MCOD1 ADRNR * INTO (GS_DATA-NAME1,GS_DATA-MCOD1,GS_DATA-ADRNR) * FROM LFA1 * WHERE LIFNR = GS_DATA-LIFNR. * * READ TABLE GT_MAIL INTO GS_MAIL WITH KEY ADRNR = GS_DATA-ADRNR BINARY SEARCH. * IF SY-SUBRC NE 0. * SELECT ADDRNUMBER SMTP_ADDR APPENDING TABLE GT_MAIL * FROM ADR6 * WHERE ADDRNUMBER = GS_DATA-ADRNR. * SORT GT_MAIL BY ADRNR. * ENDIF. * * LOOP AT GT_MAIL INTO GS_MAIL WHERE ADRNR = GS_DATA-ADRNR. * IF GS_DATA-SMTP_ADDR IS INITIAL. * GS_DATA-SMTP_ADDR = GS_MAIL-SMTP_ADDR. * ELSE. * GS_DATA-SMTP_ADDR = GS_DATA-SMTP_ADDR && ';' && GS_MAIL-SMTP_ADDR. * ENDIF. * ENDLOOP. * * MODIFY GT_DATA FROM GS_DATA. * ENDLOOP. DATA : LV_TABIX LIKE SY-TABIX. IF GT_DATA IS INITIAL. MESSAGE S322(ZMM) DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING. ENDIF. SELECT * FROM ZNMMT037 FOR ALL ENTRIES IN @GT_DATA WHERE ZNMMT037~EBELN = @GT_DATA-EBELN INTO TABLE @DATA(LT_ZNMMT037). SORT LT_ZNMMT037 BY EBELN. DATA : LS_ZNMMT037 LIKE LINE OF LT_ZNMMT037. SELECT LFA1~LIFNR , LFA1~NAME1 , LFA1~MCOD1 FROM LFA1 WHERE LFA1~LIFNR IN @S_LIFNR INTO TABLE @DATA(LT_LFA1). SORT LT_LFA1 BY LIFNR. DATA : LS_LFA1 LIKE LINE OF LT_LFA1. SELECT ZNMMT037A~LIFNR , ZNMMT037A~EKORG , ZNMMT037A~WERKS ,ZNMMT037A~EKGRP,ZNMMT037A~EMAIL FROM ZNMMT037A FOR ALL ENTRIES IN @GT_DATA WHERE ZNMMT037A~LIFNR = @GT_DATA-LIFNR AND ZNMMT037A~EKORG = @GT_DATA-EKORG INTO TABLE @DATA(LT_ZNMMT037A) . SORT LT_ZNMMT037A BY LIFNR EKORG WERKS EKGRP . DATA : LS_ZNMMT037A LIKE LINE OF LT_ZNMMT037A. LOOP AT GT_DATA ASSIGNING FIELD-SYMBOL(<LFS_DATA>). *------------填充发送记录---------------* CLEAR LS_ZNMMT037. READ TABLE LT_ZNMMT037 INTO LS_ZNMMT037 WITH KEY EBELN = <LFS_DATA>-EBELN BINARY SEARCH. IF SY-SUBRC = 0. IF CK_WFS = 'X'. <LFS_DATA>-FLAG = 'X'. CONTINUE. ENDIF. <LFS_DATA>-ICON = '@08@'. <LFS_DATA>-MESSAGE = TEXT-002. <LFS_DATA>-ERDAT = LS_ZNMMT037-ERDAT. ENDIF. *-----------填充供应商信息名字等等--------* CLEAR LS_LFA1. READ TABLE LT_LFA1 INTO LS_LFA1 WITH KEY LIFNR = <LFS_DATA>-LIFNR BINARY SEARCH. IF SY-SUBRC = 0. <LFS_DATA>-NAME1 = LS_LFA1-NAME1. <LFS_DATA>-MCOD1 = LS_LFA1-MCOD1. ENDIF. *--------填充供应商对应的邮件地址---------* *先根据供应商采购组织工厂采购员找,再根据供应商采购组织工厂找,如果找不到,就根据供应商采购组织找 CLEAR LS_ZNMMT037A. READ TABLE LT_ZNMMT037A INTO LS_ZNMMT037A WITH KEY LIFNR = <LFS_DATA>-LIFNR EKORG = <LFS_DATA>-EKORG WERKS = <LFS_DATA>-WERKS EKGRP = <LFS_DATA>-EKGRP BINARY SEARCH. IF SY-SUBRC = 0. LOOP AT LT_ZNMMT037A INTO LS_ZNMMT037A FROM SY-TABIX. IF LS_ZNMMT037A-LIFNR = <LFS_DATA>-LIFNR AND LS_ZNMMT037A-EKORG = <LFS_DATA>-EKORG AND LS_ZNMMT037A-WERKS = <LFS_DATA>-WERKS AND LS_ZNMMT037A-EKGRP = <LFS_DATA>-EKGRP. IF <LFS_DATA>-SMTP_ADDR IS INITIAL. <LFS_DATA>-SMTP_ADDR = LS_ZNMMT037A-EMAIL && '/'. ELSE. CONCATENATE <LFS_DATA>-SMTP_ADDR LS_ZNMMT037A-EMAIL '/' INTO <LFS_DATA>-SMTP_ADDR. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. ELSE. READ TABLE LT_ZNMMT037A INTO LS_ZNMMT037A WITH KEY LIFNR = <LFS_DATA>-LIFNR EKORG = <LFS_DATA>-EKORG WERKS = <LFS_DATA>-WERKS BINARY SEARCH. IF SY-SUBRC = 0. LOOP AT LT_ZNMMT037A INTO LS_ZNMMT037A FROM SY-TABIX. IF LS_ZNMMT037A-LIFNR = <LFS_DATA>-LIFNR AND LS_ZNMMT037A-EKORG = <LFS_DATA>-EKORG AND LS_ZNMMT037A-WERKS = <LFS_DATA>-WERKS. IF <LFS_DATA>-SMTP_ADDR IS INITIAL. <LFS_DATA>-SMTP_ADDR = LS_ZNMMT037A-EMAIL && '/'. ELSE. CONCATENATE <LFS_DATA>-SMTP_ADDR LS_ZNMMT037A-EMAIL '/' INTO <LFS_DATA>-SMTP_ADDR. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. ELSE. CLEAR LS_ZNMMT037A. READ TABLE LT_ZNMMT037A INTO LS_ZNMMT037A WITH KEY LIFNR = <LFS_DATA>-LIFNR EKORG = <LFS_DATA>-EKORG WERKS = '' BINARY SEARCH. IF SY-SUBRC = 0. LOOP AT LT_ZNMMT037A INTO LS_ZNMMT037A FROM SY-TABIX. IF LS_ZNMMT037A-LIFNR = <LFS_DATA>-LIFNR AND LS_ZNMMT037A-EKORG = <LFS_DATA>-EKORG AND LS_ZNMMT037A-WERKS = ''. IF <LFS_DATA>-SMTP_ADDR IS INITIAL. <LFS_DATA>-SMTP_ADDR = LS_ZNMMT037A-EMAIL && '/'. ELSE. CONCATENATE <LFS_DATA>-SMTP_ADDR LS_ZNMMT037A-EMAIL '/' INTO <LFS_DATA>-SMTP_ADDR. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDLOOP. *end modify ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_OUTPUT_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_OUTPUT_DATA . DEFINE MAC_FCAT. CLEAR gs_fcat. gs_fcat-fieldname = &1. gs_fcat-coltext = &2. gs_fcat-key = &3. gs_fcat-ref_field = &4. gs_fcat-ref_table = &5. gs_fcat-just = &6. * IF &6 = 'R'. * gs_fcat-no_zero = 'X'. * ENDIF. if &1 = 'ICON'. gs_fcat-icon = 'X'. endif. APPEND gs_fcat TO gt_fcat. END-OF-DEFINITION. CLEAR GT_FCAT. IF SY-LANGU EQ '1'. MAC_FCAT 'EBELN' '采购订单号' '' 'EBELN' 'EKKO' ''. MAC_FCAT 'LIFNR' '供应商' '' 'LIFNR' 'LFA1' ''.. MAC_FCAT 'NAME1' '供应商名称' '' '' '' ''.. MAC_FCAT 'BEDAT' '凭证日期' ' ' '' '' ''. MAC_FCAT 'EKGRP' '采购组' ' ' '' '' ''. MAC_FCAT 'MCOD1' '简称' ' ' '' '' ''. MAC_FCAT 'SPRAS' '语言' ' ' 'SPRAS' 'NAST' ''. MAC_FCAT 'SMTP_ADDR' '供应商邮件' ' ' '' '' ''. MAC_FCAT 'ICON' '发送状态' ' ' '' '' ''. MAC_FCAT 'ERDAT' '发送日期' ' ' '' '' ''. MAC_FCAT 'MESSAGE' '消息' ' ' '' '' ''. ELSE. MAC_FCAT 'EBELN' 'PO' '' 'EBELN' 'EKKO' ''. MAC_FCAT 'LIFNR' 'Supplier' '' 'LIFNR' 'LFA1' ''.. MAC_FCAT 'NAME1' 'Supplier Name' '' '' '' ''.. MAC_FCAT 'BEDAT' 'Date' ' ' '' '' ''. MAC_FCAT 'EKGRP' 'Purchase Group' ' ' '' '' ''. MAC_FCAT 'MCOD1' 'Name For Short' ' ' '' '' ''. MAC_FCAT 'SPRAS' 'Language' ' ' 'SPRAS' 'NAST' ''. MAC_FCAT 'SMTP_ADDR' 'Email' ' ' '' '' ''. MAC_FCAT 'ICON' 'Status' ' ' '' '' ''. MAC_FCAT 'ERDAT' 'Send Date' ' ' '' '' ''. MAC_FCAT 'MESSAGE' 'Message' ' ' '' '' ''. ENDIF. GS_LAYOUT-ZEBRA = 'X'. GS_LAYOUT-CWIDTH_OPT = 'X'. GS_LAYOUT-BOX_FNAME = 'BOX'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING I_CALLBACK_PROGRAM = SY-REPID IS_LAYOUT_LVC = GS_LAYOUT IT_FIELDCAT_LVC = GT_FCAT I_SAVE = 'U' I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS' I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND' TABLES T_OUTTAB = GT_DATA EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_USER_COMMAND *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. DATA:LV_ANSWER TYPE C. DATA LR_GRID TYPE REF TO CL_GUI_ALV_GRID. DATA : LV_CLSS TYPE C . "X 代表发送给供应商和采购员 ''代表发送给采购员 CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' " IMPORTING E_GRID = LR_GRID. CALL METHOD LR_GRID->CHECK_CHANGED_DATA. CASE R_UCOMM. WHEN 'EMAIL'. "保存事件 LV_CLSS = 'X'. LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X' AND ICON NE '@08@'. IF GS_DATA-SMTP_ADDR IS NOT INITIAL. PERFORM FRM_SEND_MAIL USING GS_DATA-EBELN GS_DATA-SPRAS GS_DATA-EKGRP GS_DATA-MCOD1 GS_DATA-BUKRS GS_DATA-SMTP_ADDR LV_CLSS CHANGING GS_DATA-ICON GS_DATA-MESSAGE GS_DATA-ERDAT. ELSE. GS_DATA-ICON = '@0A@'. GS_DATA-MESSAGE = TEXT-003 ." ENDIF. MODIFY GT_DATA FROM GS_DATA. ENDLOOP. *ADD BY SONGJIARU 20200519 增加只发送给采购员 WHEN 'EMAIL1'. LV_CLSS = ''. LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X' AND ICON NE '@08@'. * IF GS_DATA-SMTP_ADDR IS NOT INITIAL. PERFORM FRM_SEND_MAIL USING GS_DATA-EBELN GS_DATA-SPRAS GS_DATA-EKGRP GS_DATA-MCOD1 * GS_DATA-ADRNR GS_DATA-BUKRS GS_DATA-SMTP_ADDR LV_CLSS CHANGING GS_DATA-ICON GS_DATA-MESSAGE GS_DATA-ERDAT. * ELSE. * GS_DATA-ICON = '@0A@'. * GS_DATA-MESSAGE = '邮件为空,不能发送' ." * ENDIF. MODIFY GT_DATA FROM GS_DATA. ENDLOOP. WHEN 'DOWN'. LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X'. PERFORM FRM_DOWN_PDF USING GS_DATA-EBELN GS_DATA-SPRAS. ENDLOOP. WHEN '&IC1'. IF RS_SELFIELD-FIELDNAME = 'EBELN'. READ TABLE GT_DATA INTO GS_DATA INDEX RS_SELFIELD-TABINDEX. IF SY-SUBRC = 0. SET PARAMETER ID 'BES' FIELD GS_DATA-EBELN. CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN. ENDIF. ENDIF. WHEN OTHERS. ENDCASE. RS_SELFIELD-REFRESH = 'X'."刷新ALV报表 RS_SELFIELD-COL_STABLE = 'X'. RS_SELFIELD-ROW_STABLE = 'X'. ENDFORM. "FRM_USER_COMMAND *&---------------------------------------------------------------------* *& Form frm_set_pf_status2 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->RT_EXTAB text *----------------------------------------------------------------------* FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS 'PF_STATUS'. ENDFORM. "FRM_SET_PF_STATUS *&---------------------------------------------------------------------* *& Form FRM_SEND_MAIL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> GS_DATA_EBELN *& --> GS_DATA_SPRAS *& <-- GS_DATA_ICON *& <-- GS_DATA_MESSAGE *& <-- ELSE *&---------------------------------------------------------------------* FORM FRM_SEND_MAIL USING P_EBELN P_SPRAS P_EKGRP P_MCOD1 P_BUKRS P_EMAIL P_CLSS CHANGING P_ICON P_MESSAGE P_ERDAT. DATA:LS_ZT37 LIKE ZNMMT037. DATA:LV_BUTXT LIKE T001-BUTXT. DATA:LT_CONTENT_BIN TYPE SOLIX_TAB. DATA: CL_SEND_REQUEST TYPE REF TO CL_BCS, CL_DOCUMENT TYPE REF TO CL_DOCUMENT_BCS, CL_BCS_EXCEPTION TYPE REF TO CX_BCS, CL_SENDER TYPE REF TO IF_SENDER_BCS, CL_RECIPIENT TYPE REF TO IF_RECIPIENT_BCS. DATA: LT_MAIN_TEXT TYPE BCSY_TEXT, LS_MAIN_TEXT LIKE LINE OF LT_MAIN_TEXT, LV_TITLE TYPE SO_OBJ_DES, LV_BOOL TYPE OS_BOOLEAN. DATA:LV_PATH TYPE STRING. DATA:LT_BIN TYPE TABLE OF TBL1024. DATA LV_CONTENT TYPE XSTRING. DATA LV_VLINE TYPE I. DATA : BEGIN OF LS_RECIEVE, EMAIL TYPE AD_SMTPADR, END OF LS_RECIEVE. DATA : LT_RECIEVE LIKE TABLE OF LS_RECIEVE. DATA : LV_INDEX1 TYPE I. DATA : LV_INDEX2 TYPE I. DATA : LV_INDEX3 TYPE I. LV_PATH = 'C:\PO\' && P_EBELN && '_' && SY-UZEIT && '.PDF'. PERFORM FRM_GET_PDF USING P_EBELN P_SPRAS LV_PATH CHANGING P_ICON P_MESSAGE. IF P_ICON IS INITIAL. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = LV_PATH FILETYPE = 'BIN' IMPORTING FILELENGTH = LV_VLINE TABLES DATA_TAB = LT_BIN[]. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING INPUT_LENGTH = LV_VLINE IMPORTING BUFFER = LV_CONTENT TABLES BINARY_TAB = LT_BIN EXCEPTIONS FAILED = 1 OTHERS = 2. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = LV_CONTENT IMPORTING OUTPUT_LENGTH = LV_VLINE TABLES BINARY_TAB = LT_CONTENT_BIN. TRY. * 创建发送请求 CL_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ). SELECT SINGLE BUTXT INTO LV_BUTXT FROM T001 WHERE BUKRS = P_BUKRS. **处理标题头内容 CONCATENATE LV_BUTXT P_EBELN P_MCOD1 P_EKGRP INTO LV_TITLE SEPARATED BY SPACE. **处理邮件内容 *DG01 要求加上客制化描述 * IF P_BUKRS EQ 'DG01'. * IF SY-LANGU EQ '1'. * LS_MAIN_TEXT = * '附件是东莞长城开发新订单,请收到订单后邮件回复确认给采购员,并于3个工作日内在供应商平台上确认订单交期。供应商平台网址:https://sp.kaifa.cn '. * ELSE. * DATA(LV_STR) = 'The attachment is the new PO of Dongguan Kaifa Technology Co.,Ltd,' * && 'Please reply to the buyer after receiving the PO, and confirm the order delivery date on the supplier portal within 3 working days.' * && 'Supplier portal website(URL): https://sp.kaifa.cn '. * LS_MAIN_TEXT = LV_STR. * ENDIF. * APPEND LS_MAIN_TEXT TO LT_MAIN_TEXT. * ENDIF. * 创建整理发送内容 CL_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT( I_TYPE = 'RAW' I_TEXT = LT_MAIN_TEXT I_SUBJECT = LV_TITLE ). * 添加附件 DATA:L_OBJTP TYPE SOODK-OBJTP. DATA:L_OBJDES TYPE SOOD-OBJDES. L_OBJTP = 'PDF'. * l_objdes = p_ebeln && p_mcod1. CONCATENATE LV_BUTXT P_EBELN P_MCOD1 P_EKGRP INTO L_OBJDES SEPARATED BY SPACE. CALL METHOD CL_DOCUMENT->ADD_ATTACHMENT EXPORTING I_ATTACHMENT_TYPE = L_OBJTP I_ATTACHMENT_SUBJECT = L_OBJDES I_ATT_CONTENT_HEX = LT_CONTENT_BIN. * 添加邮件内容到发送请求 CL_SEND_REQUEST->SET_DOCUMENT( CL_DOCUMENT ). * 指定邮件发件人为采购员邮箱 * data:lv_sendtype type SX_ADDRTYP value '*', * lv_address_string type string value 'yuli@kaifa.cn', * lv_address_name type string value 'Yuli'. * cl_sender->ADDRESS_TYPE( lv_sendtype ). * cl_sender->ADDRESS_STRING( EXPORTING result = lv_address_string ). * cl_sender->ADDRESS_NAME( EXPORTING result = lv_address_name ). * cl_send_request->set_sender( cl_sender ). * data: sender type ref to cl_sapuser_bcs, * lv_uname type sy-uname value 'DTANG.IS'. * sender = cl_sapuser_bcs=>create( lv_uname ). * call method cl_send_request->set_sender * exporting * i_sender = sender. *modify by songjiaru 20200519 *----------------指定发件人----------------------------* CLEAR GS_MAIL-SMTP_ADDR. SELECT SINGLE SMTP_ADDR INTO GS_MAIL-SMTP_ADDR FROM T024 WHERE EKGRP = P_EKGRP. DATA(LO_SENDER) = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = GS_MAIL-SMTP_ADDR I_ADDRESS_NAME = GS_MAIL-SMTP_ADDR ). CALL METHOD CL_SEND_REQUEST->SET_SENDER EXPORTING I_SENDER = LO_SENDER. * "指定邮件接收人 * LOOP AT GT_MAIL INTO GS_MAIL WHERE ADRNR = P_ADRNR. * CL_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( GS_MAIL-SMTP_ADDR ). * CL_SEND_REQUEST->ADD_RECIPIENT( CL_RECIPIENT ). * ENDLOOP. IF GS_MAIL-SMTP_ADDR IS NOT INITIAL. CL_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( GS_MAIL-SMTP_ADDR ). CL_SEND_REQUEST->ADD_RECIPIENT( CL_RECIPIENT ). ENDIF. IF P_CLSS = 'X'. * CLEAR GS_MAIL-SMTP_ADDR. * SELECT SINGLE SMTP_ADDR INTO GS_MAIL-SMTP_ADDR * FROM T024 * WHERE EKGRP = P_EKGRP. LV_INDEX1 = 0. LV_INDEX2 = 0. LV_INDEX3 = 1. CLEAR LT_RECIEVE. WHILE ( LV_INDEX3 <= STRLEN( P_EMAIL ) ). LV_INDEX2 = LV_INDEX2 + 1. LV_INDEX3 = LV_INDEX3 + 1. IF P_EMAIL+LV_INDEX1(LV_INDEX2) CA '/'. LV_INDEX2 = LV_INDEX2 - 1 . LS_RECIEVE-EMAIL = P_EMAIL+LV_INDEX1(LV_INDEX2). APPEND LS_RECIEVE TO LT_RECIEVE. CLEAR LS_RECIEVE. LV_INDEX1 = LV_INDEX3 - 1. LV_INDEX2 = 0. ENDIF. ENDWHILE. LOOP AT LT_RECIEVE INTO LS_RECIEVE. CL_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( LS_RECIEVE-EMAIL ). CL_SEND_REQUEST->ADD_RECIPIENT( CL_RECIPIENT ). ENDLOOP. ENDIF. ** 正式发送并提交作业 CLEAR LV_BOOL. "将邮件置于发件箱,可以在工作台outbox查看邮件的发送状态及内容 CL_SEND_REQUEST->SEND_REQUEST->SET_LINK_TO_OUTBOX( 'X' ). CALL METHOD CL_SEND_REQUEST->SEND_REQUEST->SETU_REQUESTED_STATUS EXPORTING I_REQUESTED_STATUS = 'N'. CALL METHOD CL_SEND_REQUEST->SEND_REQUEST->SETU_STATUS_MAIL EXPORTING I_STATUS_MAIL = 'A'. CL_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ). LV_BOOL = CL_SEND_REQUEST->SEND( I_WITH_ERROR_SCREEN = 'X'). IF LV_BOOL = 'X'. COMMIT WORK. * submit rsconn01 with mode = 'INT' and return. IF LT_CONTENT_BIN IS INITIAL. P_ICON = '@0A@'. P_MESSAGE = TEXT-004. "默认导入成功 ELSE. P_ICON = '@08@'. P_MESSAGE = TEXT-005. "默认导入成功 P_ERDAT = SY-DATUM. CLEAR LS_ZT37. LS_ZT37-EBELN = P_EBELN. LS_ZT37-ERDAT = SY-DATUM. LS_ZT37-ERTIM = SY-UZEIT. LS_ZT37-ERNAM = SY-UNAME. MODIFY ZNMMT037 FROM LS_ZT37. ENDIF. ELSE. P_ICON = '@0A@'. P_MESSAGE = TEXT-006. "默认导入成功 ROLLBACK WORK. ENDIF. CATCH CX_BCS INTO CL_BCS_EXCEPTION. P_ICON = '@0A@'. P_MESSAGE = TEXT-006 && CL_BCS_EXCEPTION->ERROR_TYPE.. "默认导入成功 ENDTRY. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DOWN_PDF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> GS_DATA_EBELN *& --> GS_DATA_SPRAS *& --> GS_DATA_TDSPOOLID *&---------------------------------------------------------------------* FORM FRM_DOWN_PDF USING P_EBELN P_SPRAS. DATA:LV_ICON TYPE ICON-NAME, LV_MESSAGE TYPE C LENGTH 120. PERFORM FRM_GET_PDF USING P_EBELN P_SPRAS '' CHANGING LV_ICON LV_MESSAGE. IF LV_ICON NE ''. LV_MESSAGE = P_EBELN && LV_MESSAGE. MESSAGE LV_MESSAGE TYPE 'E' . ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_PDF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> P_EBELN *& --> P_SPRAS *& <-- P_ICON *& <-- P_MESSAGE *&---------------------------------------------------------------------* FORM FRM_GET_PDF USING P_EBELN P_SPRAS P_PATH CHANGING P_ICON P_MESSAGE. DATA:LT_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE, LS_PDF LIKE TLINE. DATA:LS_NAST LIKE NAST, LV_SUBRC TYPE SY-SUBRC, LV_VLINE TYPE I, LV_SMARTFORM_NAME TYPE RS38L_FNAM VALUE 'ZPO_FORM', " 请替换为实际的Smart Form名称 LV_TEMPLATE TYPE STXH-TDNAME VALUE 'ZPO_FORM'. " 请替换为实际的模板名称 FIELD-SYMBOLS <FS_VALUE> TYPE ITCPP. SELECT SINGLE * INTO LS_NAST FROM NAST WHERE OBJKY = P_EBELN AND SPRAS = P_SPRAS. CALL FUNCTION 'WFMC_MESSAGE_SINGLE' EXPORTING PI_NAST = LS_NAST IMPORTING PE_RCODE = LV_SUBRC. IF LV_SUBRC = 0. ASSIGN ('(SAPLMEDRUCK)RESULT') TO <FS_VALUE>. IF <FS_VALUE>-TDSPOOLID IS NOT INITIAL. CLEAR LT_PDF. " 使用Smart Forms函数替代原函数 CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING FORMNAME = ZPO_FORM IMPORTING FM_NAME = LV_FM_NAME EXCEPTIONS NO_FORM = 1 NO_FUNCTION_MODULE = 2 OTHERS = 3. IF SY-SUBRC <> 0. P_ICON = '@0A@'. P_MESSAGE = '获取Smart Forms函数失败'. EXIT. ENDIF. " 动态调用Smart Forms函数 CALL FUNCTION LV_FM_NAME EXPORTING EXPORTING = 'X' TEMPLATE = LV_TEMPLATE OUTPUT_OPTIONS = LS_OUTPUT_OPTIONS IMPORTING JOB_OUTPUT_INFO = LS_JOB_OUTPUT_INFO TABLES LINES = LT_PDF EXCEPTIONS FORMATTING_ERROR = 1 INTERNAL_ERROR = 2 SEND_ERROR = 3 USER_CANCELED = 4 OTHERS = 5. IF SY-SUBRC <> 0. P_ICON = '@0A@'. P_MESSAGE = '执行ZPO_FORM函数失败'. EXIT. ENDIF. " 计算PDF字节数 LV_VLINE = LINES( LT_PDF ). IF LT_PDF[] IS NOT INITIAL. "先下载到本地,再上载做为附件 IF P_PATH IS NOT INITIAL. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING BIN_FILESIZE = LV_VLINE FILENAME = P_PATH FILETYPE = 'BIN' TABLES DATA_TAB = LT_PDF EXCEPTIONS FILE_WRITE_ERROR = 1 NO_BATCH = 2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE = 4 NO_AUTHORITY = 5 UNKNOWN_ERROR = 6. ELSE. DATA:LV_FILE TYPE STRING. PERFORM FRM_GET_PATH USING LV_FILE. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING BIN_FILESIZE = LV_VLINE FILENAME = LV_FILE FILETYPE = 'BIN' TABLES DATA_TAB = LT_PDF EXCEPTIONS FILE_WRITE_ERROR = 1 NO_BATCH = 2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE = 4 NO_AUTHORITY = 5 UNKNOWN_ERROR = 6. ENDIF. ELSE. P_ICON = '@0A@'. P_MESSAGE = TEXT-007. "默认导入成功 ENDIF. ELSE. P_ICON = '@0A@'. P_MESSAGE = TEXT-008. "默认导入成功 ENDIF. ELSE. P_ICON = '@0A@'. P_MESSAGE = TEXT-009. "默认导入成功 ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_PATH *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> LV_PATH *&---------------------------------------------------------------------* FORM FRM_GET_PATH USING P_FILE. DATA: L_V_FILE_FILTER TYPE STRING. DATA: L_V_FILETABLE TYPE FILE_TABLE, L_T_FILETABLE TYPE FILETABLE. DATA: L_V_RC TYPE I. DATA: L_V_USER_ACTION TYPE I. * l_v_file_filter = '(*.xlsx;*.xls)|*.xlsx;*.xls|'. L_V_FILE_FILTER = '(*.PDF)|*.PDF|'. CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG( EXPORTING WINDOW_TITLE = '选择文件' FILE_FILTER = L_V_FILE_FILTER CHANGING FILE_TABLE = L_T_FILETABLE RC = L_V_RC USER_ACTION = L_V_USER_ACTION ). CHECK L_V_USER_ACTION EQ 0. CHECK L_T_FILETABLE[] IS NOT INITIAL. READ TABLE L_T_FILETABLE INTO L_V_FILETABLE INDEX 1. P_FILE = L_V_FILETABLE-FILENAME. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_MOD_SCREEN *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_MOD_SCREEN . LOOP AT SCREEN. IF SCREEN-GROUP1 = 'M1'. IF R1 = 'X'. SCREEN-ACTIVE = 1. ELSE. SCREEN-ACTIVE = 0. ENDIF. ENDIF. IF SCREEN-GROUP1 = 'M2'. IF R2 = 'X'. SCREEN-ACTIVE = 1. ELSE. SCREEN-ACTIVE = 0. ENDIF. ENDIF. IF SCREEN-GROUP1 = 'M3'. IF R3 = 'X'. SCREEN-ACTIVE = 1. ELSE. SCREEN-ACTIVE = 0. ENDIF. ENDIF. MODIFY SCREEN. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DOWN_TEMPLATE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_DOWN_TEMPLATE . CREATE OBJECT V_EXCEL 'EXCEL.APPLICATION'. SET PROPERTY OF V_EXCEL 'VISIBLE' = 1. CALL METHOD OF V_EXCEL 'WORKBOOKS' = V_BOOK . CALL METHOD OF V_BOOK 'ADD'. IF SY-LANGU EQ '1'. PERFORM FRM_FILL_CELL USING: 1 1 '供应商代码(必填)' 40 0 10, "行号,列号,值,单元格颜色,是否加粗,字体尺寸" 1 2 '采购组织(必填)' 40 0 10, "行号,列号,值,单元格颜色,是否加粗,字体尺寸" 1 3 '工厂(选填)' 40 0 10, 1 4 '采购员(选填)' 40 0 10, 1 5 '订单发送邮箱(必填)' 40 0 10. ELSE. PERFORM FRM_FILL_CELL USING: 1 1 'Vendor Code(Required)' 40 0 10, "行号,列号,值,单元格颜色,是否加粗,字体尺寸" 1 2 'Purchase Organization(Required)' 40 0 10, "行号,列号,值,单元格颜色,是否加粗,字体尺寸" 1 3 'Plant' 40 0 10, 1 4 'Buyer.Code' 40 0 10, " add buyer code 20210413 wahkenlee 1 5 'Email' 40 0 10. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_FILL_CELL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> P_1 *& --> P_1 *& --> P_ *& --> P_40 *& --> P_0 *& --> P_10 *&---------------------------------------------------------------------* FORM FRM_FILL_CELL USING FU_ROW FU_COLUMN FU_VALUE FU_COLOR FU_BOLD FU_SIZE. DATA: L_CELL TYPE OLE2_OBJECT, L_COLOR TYPE OLE2_OBJECT, L_BOLD TYPE OLE2_OBJECT, L_COLUMN TYPE OLE2_OBJECT. CALL METHOD OF V_EXCEL 'CELLS' = L_CELL EXPORTING #1 = FU_ROW #2 = FU_COLUMN. SET PROPERTY OF L_CELL 'Value' = FU_VALUE. "赋值。" * call method of L_CELL 'INTERIOR' = int. GET PROPERTY OF L_CELL 'Interior' = L_COLOR. SET PROPERTY OF L_COLOR 'ColorIndex' = FU_COLOR. "根据值 显示对应的颜色。 GET PROPERTY OF L_CELL 'Font' = L_BOLD. SET PROPERTY OF L_BOLD 'Bold' = FU_BOLD. "1是加粗,0是不加粗" SET PROPERTY OF L_BOLD 'SIZE' = FU_SIZE. "设置字体大小。" CALL METHOD OF V_EXCEL 'Columns' = L_COLUMN " 选定列 EXPORTING #1 = FU_COLUMN . SET PROPERTY OF L_COLUMN 'ColumnWidth' = 20. " 定义列宽 SET PROPERTY OF L_COLUMN 'rowheight' = 24. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_MAINTAIN_EMAIL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_MAINTAIN_EMAIL . PERFORM FRM_CHECK_AUTH. PERFORM FRM_UPLOAD_DATA. PERFORM FRM_CHECK_DATA. PERFORM FRM_UPDATE_DATA. PERFORM FRM_ALV. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_UPLOAD_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_UPLOAD_DATA . CLEAR : GS_ITEM ,GT_ITEM. CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING FILENAME = GV_FILE I_BEGIN_COL = 1 I_BEGIN_ROW = 2 I_END_COL = 5 I_END_ROW = 65535 TABLES INTERN = GT_ALSM EXCEPTIONS INCONSISTENT_PARAMETERS = 1 UPLOAD_OLE = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE S000(ZMM) WITH TEXT-010 DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING. ENDIF. * 转换数据 LOOP AT GT_ALSM. ASSIGN COMPONENT GT_ALSM-COL OF STRUCTURE GS_ITEM TO <GFS_DATA>. TRANSLATE GT_ALSM-VALUE TO UPPER CASE. <GFS_DATA> = GT_ALSM-VALUE. AT END OF ROW. APPEND GS_ITEM TO GT_ITEM. CLEAR GS_ITEM. ENDAT. ENDLOOP. LOOP AT GT_ITEM ASSIGNING FIELD-SYMBOL(<LFS_ITEM>). CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING INPUT = <LFS_ITEM>-LIFNR IMPORTING OUTPUT = <LFS_ITEM>-LIFNR. ENDLOOP. IF GT_ITEM IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-011 DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CHECK_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_CHECK_DATA . DATA LV_NAME TYPE STRING . data:ls_email_stru type SX_ADDRESS, ls_email_stru_out type SX_ADDRESS. *前面已经判断过gt_item 不为空 SELECT LFA1~LIFNR , LFA1~NAME1 INTO TABLE @GT_LFA1 FROM LFA1 FOR ALL ENTRIES IN @GT_ITEM WHERE LFA1~LIFNR = @GT_ITEM-LIFNR. SORT GT_LFA1 BY LIFNR . SELECT T024E~EKORG , T001K~BWKEY FROM T024E INNER JOIN T001K ON T024E~BUKRS = T001K~BUKRS FOR ALL ENTRIES IN @GT_ITEM WHERE T024E~EKORG = @GT_ITEM-EKORG INTO TABLE @DATA(LT_T024E). SELECT T024~EKGRP FROM T024 FOR ALL ENTRIES IN @GT_ITEM WHERE T024~EKGRP = @GT_ITEM-EKGRP INTO TABLE @DATA(LT_T024). SORT LT_T024E BY EKORG BWKEY. SORT LT_T024 BY EKGRP. DATA LS_T024E LIKE LINE OF LT_T024E. DATA LS_T024 LIKE LINE OF LT_T024. LOOP AT GT_ITEM INTO GS_ITEM. MOVE-CORRESPONDING GS_ITEM TO GS_MESSAGE. CLEAR GS_LFA1. READ TABLE GT_LFA1 INTO GS_LFA1 WITH KEY LIFNR = GS_ITEM-LIFNR BINARY SEARCH . IF SY-SUBRC <> 0. GS_MESSAGE-MESSAGE = TEXT-012. GS_MESSAGE-FLAG = 'X'. ELSE. GS_MESSAGE-NAME1 = GS_LFA1-NAME1. ENDIF. IF GS_ITEM-EKORG IS INITIAL. CONCATENATE GS_MESSAGE-MESSAGE TEXT-013 INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. ENDIF. IF GS_ITEM-WERKS IS NOT INITIAL AND GS_ITEM-EKORG IS NOT INITIAL. CLEAR LS_T024E. READ TABLE LT_T024E INTO LS_T024E WITH KEY EKORG = GS_ITEM-EKORG BWKEY = GS_ITEM-WERKS BINARY SEARCH. IF SY-SUBRC <> 0. CONCATENATE GS_MESSAGE-MESSAGE TEXT-014 INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. ENDIF. ENDIF. IF GS_ITEM-EMAIL IS INITIAL. CONCATENATE GS_MESSAGE-MESSAGE '' INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. ELSE. "校验导入邮箱的格式 ls_email_stru-type = 'INT'. ls_email_stru-address = gs_item-email. CALL FUNCTION 'SX_INTERNET_ADDRESS_TO_NORMAL' EXPORTING ADDRESS_UNSTRUCT = ls_email_stru IMPORTING ADDRESS_NORMAL = ls_email_stru_out EXCEPTIONS ERROR_ADDRESS_TYPE = 1 ERROR_ADDRESS = 2 ERROR_GROUP_ADDRESS = 3 OTHERS = 4. if ls_email_stru is INITIAL. CONCATENATE GS_MESSAGE-MESSAGE TEXT-025 INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. endif. ENDIF. CALL FUNCTION 'ZMM_GET_DOMAIN' IMPORTING DOMAIN_NAME = LV_NAME. IF LV_NAME IS INITIAL. CONCATENATE GS_MESSAGE-MESSAGE TEXT-016 INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. ELSE. GS_MESSAGE-UNAME = LV_NAME. ENDIF. IF GS_ITEM-EKGRP IS NOT INITIAL. CLEAR:LS_T024. READ TABLE LT_T024 INTO LS_T024 WITH KEY EKGRP = GS_ITEM-EKGRP. IF SY-SUBRC <> 0. CONCATENATE GS_MESSAGE-MESSAGE TEXT-024 INTO GS_MESSAGE-MESSAGE. GS_MESSAGE-FLAG = 'X'. ENDIF. ENDIF. IF GS_MESSAGE-FLAG <> 'X'. CONCATENATE TEXT-017 SY-DATUM+0(4) '/' SY-DATUM+4(2) '/' SY-DATUM+6(2) TEXT-018 SYST-UZEIT+0(2) ':' SYST-UZEIT+2(2) ':' SYST-UZEIT+4(2) INTO GS_MESSAGE-MESSAGE. ENDIF. APPEND GS_MESSAGE TO GT_MESSAGE. CLEAR GS_MESSAGE. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_UPDATE_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_UPDATE_DATA . DATA : LT_ZNMMT037A TYPE TABLE OF ZNMMT037A. DATA : LS_ZNMMT037A LIKE LINE OF LT_ZNMMT037A. LOOP AT GT_MESSAGE INTO GS_MESSAGE WHERE FLAG <> 'X'. MOVE-CORRESPONDING GS_MESSAGE TO LS_ZNMMT037A. APPEND LS_ZNMMT037A TO LT_ZNMMT037A. CLEAR LS_ZNMMT037A. ENDLOOP. IF LT_ZNMMT037A IS NOT INITIAL. MODIFY ZNMMT037A FROM TABLE LT_ZNMMT037A. IF SY-DBCNT <> 0. COMMIT WORK. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ALV *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_ALV . CLEAR GT_FIELDCAT. CLEAR GS_FIELDCAT. CLEAR GT_EVENTS. CLEAR GS_EVENTS. CLEAR GS_LAYOUT1. MOVE-CORRESPONDING GT_MESSAGE TO GT_EMAIL_ALV. IF SY-LANGU EQ '1'. GMRC_INITIAL_FIELD '供应商代码' 'LIFNR' 'X'. GMRC_INITIAL_FIELD '供应商名称' 'NAME1' 'X'. GMRC_INITIAL_FIELD '采购组织' 'EKORG' 'X'. GMRC_INITIAL_FIELD '工厂' 'WERKS' 'X'. GMRC_INITIAL_FIELD '采购员' 'EKGRP' 'X'. GMRC_INITIAL_FIELD '订单发送邮箱' 'EMAIL' 'X'. GMRC_INITIAL_FIELD '用户域名' 'UNAME' 'X'. GMRC_INITIAL_FIELD '信息' 'MESSAGE' ''. ELSE. GMRC_INITIAL_FIELD 'Supplier Code' 'LIFNR' 'X'. GMRC_INITIAL_FIELD 'Supplier Name' 'NAME1' 'X'. GMRC_INITIAL_FIELD 'Purchase Organization' 'EKORG' 'X'. GMRC_INITIAL_FIELD 'Plant' 'WERKS' 'X'. GMRC_INITIAL_FIELD 'Buyer.Code' 'EKGRP' 'X'. GMRC_INITIAL_FIELD 'Email' 'EMAIL' 'X'. GMRC_INITIAL_FIELD 'Domain' 'UNAME' 'X'. GMRC_INITIAL_FIELD 'Message' 'MESSAGE' ''. ENDIF. GS_LAYOUT1-COLWIDTH_OPTIMIZE = 'X'. GS_LAYOUT1-ZEBRA = 'X'. MOVE 'PF_STATUS_SET' TO GS_EVENTS-NAME. MOVE 'FRM_SET_PF_STATUS1' TO GS_EVENTS-FORM. APPEND GS_EVENTS TO GT_EVENTS. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' I_CALLBACK_PROGRAM = SY-REPID * I_CALLBACK_PF_STATUS_SET = '' I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND2' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * I_STRUCTURE_NAME = * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = IS_LAYOUT = GS_LAYOUT1 IT_FIELDCAT = GT_FIELDCAT * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = I_DEFAULT = 'X' * I_SAVE = 'A ' * IS_VARIANT = IT_EVENTS = GT_EVENTS * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * I_HTML_HEIGHT_TOP = 0 * I_HTML_HEIGHT_END = 0 * IT_ALV_GRAPHICS = * IT_HYPERLINK = * IT_ADD_FIELDCAT = * IT_EXCEPT_QINFO = * IR_SALV_FULLSCREEN_ADAPTER = * O_PREVIOUS_SRAL_HANDLER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES T_OUTTAB = GT_EMAIL_ALV EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. FORM FRM_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS'0100' . ENDFORM. FORM FRM_SET_PF_STATUS1 USING RT_EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS'0200' . ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_QUERY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_QUERY . CLEAR : GT_QUERY_ALV. CLEAR : GS_QUERY_ALV. CLEAR GT_FIELDCAT. CLEAR GS_FIELDCAT. CLEAR GT_EVENTS. CLEAR GS_EVENTS. CLEAR GS_LAYOUT1. SELECT ZNMMT037A~LIFNR , ZNMMT037A~NAME1 , ZNMMT037A~EKORG , ZNMMT037A~WERKS , ZNMMT037A~EMAIL , ZNMMT037A~UNAME , ZNMMT037A~MESSAGE , ZNMMT037A~EKGRP FROM ZNMMT037A WHERE ZNMMT037A~LIFNR IN @S_LIFNR1 AND ZNMMT037A~EKORG IN @S_EKORG1 AND ZNMMT037A~WERKS IN @S_WERKS INTO TABLE @DATA(LT_ZNMMT037A) . MOVE-CORRESPONDING LT_ZNMMT037A TO GT_QUERY_ALV. IF SY-LANGU EQ '1'. GMRC_INITIAL_FIELD '供应商代码' 'LIFNR' 'X'. GMRC_INITIAL_FIELD '供应商名称' 'NAME1' 'X'. GMRC_INITIAL_FIELD '采购组织' 'EKORG' 'X'. GMRC_INITIAL_FIELD '工厂' 'WERKS' 'X'. GMRC_INITIAL_FIELD '采购员' 'EKGRP' 'X'. GMRC_INITIAL_FIELD '订单发送邮箱' 'EMAIL' 'X'. GMRC_INITIAL_FIELD '用户域名' 'UNAME' 'X'. GMRC_INITIAL_FIELD '信息' 'MESSAGE' ''. ELSE. GMRC_INITIAL_FIELD 'Supplier Code' 'LIFNR' 'X'. GMRC_INITIAL_FIELD 'Supplier Name' 'NAME1' 'X'. GMRC_INITIAL_FIELD 'Purchase Organization' 'EKORG' 'X'. GMRC_INITIAL_FIELD 'Plant' 'WERKS' 'X'. GMRC_INITIAL_FIELD 'Buyer.Code' 'EKGRP' 'X'. GMRC_INITIAL_FIELD 'Email' 'EMAIL' 'X'. GMRC_INITIAL_FIELD 'DOMAIN_NAME' 'UNAME' 'X'. GMRC_INITIAL_FIELD 'Message' 'MESSAGE' ''. ENDIF. GS_LAYOUT1-COLWIDTH_OPTIMIZE = 'X'. GS_LAYOUT1-ZEBRA = 'X'. GS_LAYOUT1-BOX_FIELDNAME = 'BOX'. MOVE 'PF_STATUS_SET' TO GS_EVENTS-NAME. MOVE 'FRM_SET_PF_STATUS' TO GS_EVENTS-FORM. APPEND GS_EVENTS TO GT_EVENTS. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' I_CALLBACK_PROGRAM = SY-REPID * I_CALLBACK_PF_STATUS_SET = '' I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND1' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * I_STRUCTURE_NAME = * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = IS_LAYOUT = GS_LAYOUT1 IT_FIELDCAT = GT_FIELDCAT * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = I_DEFAULT = 'X' * I_SAVE = 'A ' * IS_VARIANT = IT_EVENTS = GT_EVENTS * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * I_HTML_HEIGHT_TOP = 0 * I_HTML_HEIGHT_END = 0 * IT_ALV_GRAPHICS = * IT_HYPERLINK = * IT_ADD_FIELDCAT = * IT_EXCEPT_QINFO = * IR_SALV_FULLSCREEN_ADAPTER = * O_PREVIOUS_SRAL_HANDLER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES T_OUTTAB = GT_QUERY_ALV EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. FORM FRM_USER_COMMAND1 USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. CASE R_UCOMM. WHEN 'BACK' OR 'CANCEL' OR 'EXIT'. DATA : LV_SELTAB TYPE TABLE OF RSPARAMS. CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS' "获取当前的选择屏幕元素 EXPORTING CURR_REPORT = SY-REPID * IMPORTING * SP = TABLES SELECTION_TABLE = LV_SELTAB * SELECTION_TABLE_255 = EXCEPTIONS NOT_FOUND = 1 NO_REPORT = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. "使用获取到的屏幕元素跳转初始界面 SUBMIT ZNMMR037 WITH SELECTION-TABLE LV_SELTAB VIA SELECTION-SCREEN. WHEN 'DELETE'. IF R2 = 'X'. PERFORM FRM_DELETE_DATA. ENDIF. WHEN OTHERS. ENDCASE. ENDFORM. FORM FRM_USER_COMMAND2 USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. CASE R_UCOMM. WHEN 'BACK' OR 'CANCEL' OR 'EXIT'. LEAVE TO SCREEN 0. WHEN OTHERS. ENDCASE. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DELETE_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_DELETE_DATA . DATA : LS_COUNT TYPE I VALUE 0."删除记录的条数 DATA : LT_ZNMMT037A TYPE TABLE OF ZNMMT037A. DATA : LS_ZNMMT037A TYPE ZNMMT037A. DATA : LT_ALV LIKE GT_QUERY_ALV. DATA : LS_ALV LIKE LINE OF LT_ALV. CLEAR : LT_ZNMMT037A, LS_ZNMMT037A, LT_ALV, LS_ALV. LOOP AT GT_QUERY_ALV INTO GS_QUERY_ALV. IF GS_QUERY_ALV-BOX EQ 'X'. MOVE-CORRESPONDING GS_QUERY_ALV TO LS_ALV. APPEND LS_ALV TO LT_ALV. CLEAR LS_ALV. LS_ZNMMT037A-LIFNR = GS_QUERY_ALV-LIFNR. LS_ZNMMT037A-EKORG = GS_QUERY_ALV-EKORG. LS_ZNMMT037A-WERKS = GS_QUERY_ALV-WERKS. LS_ZNMMT037A-EMAIL = GS_QUERY_ALV-EMAIL. LS_ZNMMT037A-EKGRP = GS_QUERY_ALV-EKGRP. APPEND LS_ZNMMT037A TO LT_ZNMMT037A. CLEAR LS_ZNMMT037A. ENDIF. ENDLOOP. IF LT_ZNMMT037A IS INITIAL. MESSAGE E322(ZMM) DISPLAY LIKE 'W'. ENDIF. DELETE ZNMMT037A FROM TABLE LT_ZNMMT037A. IF SY-SUBRC EQ 0. COMMIT WORK AND WAIT. LOOP AT LT_ALV INTO LS_ALV. DELETE TABLE GT_QUERY_ALV FROM LS_ALV. LS_COUNT = LS_COUNT + 1. ENDLOOP. MESSAGE S104(ZMM) WITH LS_COUNT. DATA: LV_REF_GRID TYPE REF TO CL_GUI_ALV_GRID, LV_VALID TYPE C. IF LV_REF_GRID IS INITIAL. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING E_GRID = LV_REF_GRID. ENDIF. IF NOT LV_REF_GRID IS INITIAL. LV_REF_GRID->CHECK_CHANGED_DATA( IMPORTING E_VALID = LV_VALID ). ENDIF. IF LV_VALID IS NOT INITIAL. LV_REF_GRID->REFRESH_TABLE_DISPLAY( ) . ENDIF. ELSE. ROLLBACK WORK. MESSAGE E105(ZMM). ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CHECK_AUTH *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_CHECK_AUTH . DATA LV_NAME TYPE STRING . CALL FUNCTION 'ZMM_GET_DOMAIN' IMPORTING DOMAIN_NAME = LV_NAME. SELECT SINGLE ZNMMT037B~DOMAIN_USER INTO @DATA(LV_DOMAIN) FROM ZNMMT037B WHERE ZPROGRAM = 'ZNMMR037' AND DOMAIN_USER = @LV_NAME. SELECT SINGLE ZNMMT037B~UNAME INTO @DATA(LV_UNAME) FROM ZNMMT037B WHERE ZPROGRAM = 'ZNMMR037' AND UNAME = @SY-UNAME. IF LV_DOMAIN IS INITIAL AND LV_UNAME IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-019 DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CHECK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_CHECK . DATA: LV_STRING TYPE STRING. DATA : LV_NAME TYPE STRING. FIELD-SYMBOLS : <LFS_WERKS> LIKE GS_WERKS. CLEAR GT_WERKS. CLEAR GS_WERKS. IF S_WERKS1[] IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-023. LEAVE LIST-PROCESSING. ELSE. CALL FUNCTION 'ZMM_GET_DOMAIN' IMPORTING DOMAIN_NAME = LV_NAME. SELECT ZME2M_PLANT~UNAME , ZME2M_PLANT~USER_DOMAIN ,ZME2M_PLANT~WERKS_LIST FROM ZME2M_PLANT WHERE ZME2M_PLANT~USER_DOMAIN = @LV_NAME INTO TABLE @DATA(LT_PLANT). SORT LT_PLANT BY WERKS_LIST. SELECT T001W~WERKS FROM T001W WHERE T001W~WERKS IN @S_WERKS1 INTO CORRESPONDING FIELDS OF TABLE @GT_WERKS. SORT GT_WERKS BY WERKS. IF GT_WERKS IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-022 DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING. ENDIF. IF LT_PLANT IS NOT INITIAL."在单点登录权限里面的用户在需要检查,不在里面的不需要检查 LOOP AT LT_PLANT INTO DATA(LS_PLANT). READ TABLE GT_WERKS WITH KEY WERKS = LS_PLANT-WERKS_LIST TRANSPORTING NO FIELDS BINARY SEARCH. IF SY-SUBRC <> 0. DELETE GT_WERKS WHERE WERKS = LS_PLANT-WERKS_LIST. ENDIF. ENDLOOP. ENDIF. IF GT_WERKS IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-021. LEAVE LIST-PROCESSING . ENDIF. LOOP AT GT_WERKS ASSIGNING <LFS_WERKS> . AUTHORITY-CHECK OBJECT 'M_BEST_WRK' ID 'ACTVT' FIELD '03' ID 'WERKS' FIELD <LFS_WERKS>-WERKS. IF SY-SUBRC <> 0. <LFS_WERKS>-FLAG = 'X'. ENDIF. ENDLOOP. DELETE GT_WERKS WHERE FLAG = 'X'. IF GT_WERKS IS INITIAL. MESSAGE S000(ZMM) WITH TEXT-020 DISPLAY LIKE 'W'. LEAVE LIST-PROCESSING . ENDIF. ENDIF. CLEAR S_WERKS1[]. CLEAR S_WERKS1. LOOP AT GT_WERKS INTO GS_WERKS. S_WERKS1-SIGN = 'I'. S_WERKS1-OPTION = 'EQ'. S_WERKS1-LOW = GS_WERKS-WERKS. APPEND S_WERKS1. CLEAR S_WERKS1. ENDLOOP. ENDFORM.需优化为SAP Smartform模式,
最新发布
05-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值