2015年8月24日 星期一

iDempiere 醫管資訊系統

iDempiere 醫管資訊系統
如何抓取台灣土產系統杏樹飛翔醫院管理系統
用生身證號去取得病歷號
IDNO  REGNO
用病歷號去取的所有診間醫令
REGNO CASENO TEST(CODE)
去取得各種檢檢驗結果


NLS_LANG=TRADITIONAL CHINESE_TAIWAN.ZHT16MSWIN950

2015年4月7日 星期二

iDempiere 系統配置

    public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
    public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
    public static final String ALLOW_APPLY_PAYMENT_TO_CREDITMEMO = "ALLOW_APPLY_PAYMENT_TO_CREDITMEMO";
    public static final String ALLOW_OVER_APPLIED_PAYMENT = "ALLOW_OVER_APPLIED_PAYMENT";
    public static final String ALogin_ShowOneRole = "ALogin_ShowOneRole";
    public static final String APPLICATION_DATABASE_VERSION = "APPLICATION_DATABASE_VERSION";
    public static final String APPLICATION_DATABASE_VERSION_SHOWN = "APPLICATION_DATABASE_VERSION_SHOWN";
    public static final String APPLICATION_HOST_SHOWN = "APPLICATION_HOST_SHOWN";  
    public static final String APPLICATION_IMPLEMENTATION_VENDOR = "APPLICATION_IMPLEMENTATION_VENDOR";
    public static final String APPLICATION_IMPLEMENTATION_VENDOR_SHOWN = "APPLICATION_IMPLEMENTATION_VENDOR_SHOWN";
    public static final String APPLICATION_JVM_VERSION_SHOWN = "APPLICATION_JVM_VERSION_SHOWN";
    public static final String APPLICATION_MAIN_VERSION = "APPLICATION_MAIN_VERSION";
    public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN";
    public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN";
    public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED";
    public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT";
    public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM";
    public static final String BACKGROUND_JOB_MAX_PER_CLIENT = "BACKGROUND_JOB_MAX_PER_CLIENT";
    public static final String BACKGROUND_JOB_MAX_PER_USER = "BACKGROUND_JOB_MAX_PER_USER";
    public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE";
    public static final String CASH_AS_PAYMENT = "CASH_AS_PAYMENT";
    public static final String CHANGE_PASSWORD_MUST_DIFFER = "CHANGE_PASSWORD_MUST_DIFFER";
    public static final String CHECK_CREDIT_ON_CASH_POS_ORDER = "CHECK_CREDIT_ON_CASH_POS_ORDER";
    public static final String CHECK_CREDIT_ON_PREPAY_ORDER = "CHECK_CREDIT_ON_PREPAY_ORDER";
    public static final String CLIENT_ACCOUNTING = "CLIENT_ACCOUNTING";
    public static final String DEFAULT_COA_PATH = "DEFAULT_COA_PATH";
    public static final String DICTIONARY_ID_COMMENTS = "DICTIONARY_ID_COMMENTS";
    public static final String DICTIONARY_ID_PASSWORD = "DICTIONARY_ID_PASSWORD";
    public static final String DICTIONARY_ID_USE_CENTRALIZED_ID = "DICTIONARY_ID_USE_CENTRALIZED_ID";
    public static final String DICTIONARY_ID_USER = "DICTIONARY_ID_USER";
    public static final String DICTIONARY_ID_WEBSITE = "DICTIONARY_ID_WEBSITE";
    public static final String DOCACTIONBUTTON_SHOWACTIONNAME = "DOCACTIONBUTTON_SHOWACTIONNAME";
    public static final String DPVIEWS_SHOWINFOACCOUNT = "DPViews_ShowInfoAccount";
    public static final String DPVIEWS_SHOWINFOSCHEDULE = "DPViews_ShowInfoSchedule";
    public static final String ENABLE_PAYMENTBOX_BUTTON = "ENABLE_PAYMENTBOX_BUTTON";
    public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS";
    public static final String HTML_REPORT_THEME = "HTML_REPORT_THEME";
    public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber";
    public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES";
    public static final String LASTRUN_RECORD_COUNT = "LASTRUN_RECORD_COUNT";
    public static final String LOCATION_MAPS_DESTINATION_ADDRESS = "LOCATION_MAPS_DESTINATION_ADDRESS";
    public static final String LOCATION_MAPS_ROUTE_PREFIX = "LOCATION_MAPS_ROUTE_PREFIX";
    public static final String LOCATION_MAPS_SOURCE_ADDRESS = "LOCATION_MAPS_SOURCE_ADDRESS";
    public static final String LOCATION_MAPS_URL_PREFIX = "LOCATION_MAPS_URL_PREFIX";
    public static final String LOCATION_MAX_CITY_ROWS = "LOCATION_MAX_CITY_ROWS";
    public static final String LOGIN_HELP_URL = "LOGIN_HELP_URL";
    public static final String LOGIN_SHOW_RESETPASSWORD = "LOGIN_SHOW_RESETPASSWORD";
    public static final String MAIL_DONT_SEND_TO_ADDRESS = "MAIL_DONT_SEND_TO_ADDRESS";
    public static final String MAIL_SEND_BCC_TO_ADDRESS = "MAIL_SEND_BCC_TO_ADDRESS";
    public static final String MAIL_SEND_BCC_TO_FROM = "MAIL_SEND_BCC_TO_FROM";
    public static final String MAIL_SEND_CREDENTIALS = "MAIL_SEND_CREDENTIALS";
    public static final String MAX_ACTIVITIES_IN_LIST = "MAX_ACTIVITIES_IN_LIST";
    public static final String MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER = "MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER";
    public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS";
    public static final String MFG_ValidateCostsDifferenceOnCreate = "MFG_ValidateCostsDifferenceOnCreate";
    public static final String MFG_ValidateCostsOnCreate = "MFG_ValidateCostsOnCreate";
    public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT";
    public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_RECEIPT";
    public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CREDIT_CARD";
    public static final String PAYMENT_SELECTION_MANUAL_ASK_INVOKE_GENERATE = "PAYMENT_SELECTION_MANUAL_ASK_INVOKE_GENERATE";
    public static final String PDF_FONT_DIR = "PDF_FONT_DIR";
    public static final String ProductUOMConversionRateValidate = "ProductUOMConversionRateValidate";
    public static final String ProductUOMConversionUOMValidate = "ProductUOMConversionUOMValidate";
    public static final String PROJECT_ID_COMMENTS = "PROJECT_ID_COMMENTS";
    public static final String PROJECT_ID_PASSWORD = "PROJECT_ID_PASSWORD";
    public static final String PROJECT_ID_PROJECT = "PROJECT_ID_PROJECT";
    public static final String PROJECT_ID_USE_CENTRALIZED_ID = "PROJECT_ID_USE_CENTRALIZED_ID";
    public static final String PROJECT_ID_USER = "PROJECT_ID_USER";
    public static final String PROJECT_ID_WEBSITE = "PROJECT_ID_WEBSITE";
    public static final String REAL_TIME_POS = "REAL_TIME_POS";
    public static final String RecentItems_MaxSaved = "RecentItems_MaxSaved";
    public static final String RecentItems_MaxShown = "RecentItems_MaxShown";
    public static final String REPORT_SWAP_MAX_ROWS = "REPORT_SWAP_MAX_ROWS";
    public static final String SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE = "SHIPPING_DEFAULT_WEIGHT_PER_PACKAGE";
    public static final String STANDARD_REPORT_FOOTER_TRADEMARK_TEXT = "STANDARD_REPORT_FOOTER_TRADEMARK_TEXT";
    public static final String START_VALUE_BPLOCATION_NAME = "START_VALUE_BPLOCATION_NAME";
    public static final String SWING_LOGIN_ALLOW_REMEMBER_ME = "SWING_LOGIN_ALLOW_REMEMBER_ME";
    public static final String SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR = "SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR";
    public static final String SYSCONFIG_INFO_DEFAULTSELECTED = "SYSCONFIG_INFO_DEFAULTSELECTED";
    public static final String SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION = "SYSCONFIG_INFO_DOUBLECLICKTOGGLESSELECTION";
    public static final String SYSTEM_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE";
    public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG";
    public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE";
    public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS";
    public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN";
    public static final String USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES = "USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES";
    public static final String USER_LOCKING_MAX_INACTIVE_PERIOD_DAY = "USER_LOCKING_MAX_INACTIVE_PERIOD_DAY";
    public static final String USER_LOCKING_MAX_LOGIN_ATTEMPT = "USER_LOCKING_MAX_LOGIN_ATTEMPT";
    public static final String USER_LOCKING_MAX_PASSWORD_AGE_DAY = "USER_LOCKING_MAX_PASSWORD_AGE_DAY";
    public static final String USER_PASSWORD_HASH = "USER_PASSWORD_HASH";
    public static final String VALIDATE_MATCHING_TO_ORDERED_QTY = "VALIDATE_MATCHING_TO_ORDERED_QTY";
    public static final String WEBUI_LOGOURL = "WEBUI_LOGOURL";
    public static final String ZK_BROWSER_ICON = "ZK_BROWSER_ICON";
    public static final String ZK_BROWSER_TITLE = "ZK_BROWSER_TITLE";
    public static final String ZK_BUTTON_STYLE = "ZK_BUTTON_STYLE";
    public static final String ZK_DASHBOARD_PERFORMANCE_TIMEOUT = "ZK_DASHBOARD_PERFORMANCE_TIMEOUT";
    public static final String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL";
    public static final String ZK_DECIMALBOX_PROCESS_DOTKEYPAD = "ZK_DECIMALBOX_PROCESS_DOTKEYPAD";
    public static final String ZK_DESKTOP_CLASS = "ZK_DESKTOP_CLASS";
    public static final String ZK_FOOTER_SERVER_DATETIME_FORMAT = "ZK_FOOTER_SERVER_DATETIME_FORMAT";
    public static final String ZK_FOOTER_SERVER_MSG = "ZK_FOOTER_SERVER_MSG";
    public static final String ZK_GRID_EDIT_MODELESS = "ZK_GRID_EDIT_MODELESS";
    public static final String ZK_LOGIN_ALLOW_REMEMBER_ME = "ZK_LOGIN_ALLOW_REMEMBER_ME";
    public static final String ZK_LOGO_LARGE = "ZK_LOGO_LARGE";
    public static final String ZK_LOGO_SMALL = "ZK_LOGO_SMALL";
    public static final String ZK_MAX_UPLOAD_SIZE = "ZK_MAX_UPLOAD_SIZE";
    public static final String ZK_PAGING_SIZE = "ZK_PAGING_SIZE";
    public static final String ZK_REPORT_FORM_OUTPUT_TYPE = "ZK_REPORT_FORM_OUTPUT_TYPE";
    public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE";
    public static final String ZK_REPORT_TABLE_OUTPUT_TYPE = "ZK_REPORT_TABLE_OUTPUT_TYPE";
    public static final String ZK_ROOT_FOLDER_BROWSER = "ZK_ROOT_FOLDER_BROWSER";
    public static final String ZK_SESSION_TIMEOUT_IN_SECONDS = "ZK_SESSION_TIMEOUT_IN_SECONDS";
    public static final String ZK_THEME = "ZK_THEME";

iDempiere 要更改 [ 導入供應商 ]

要更改 [ 導入供應商 ]

String vendor = MSysConfig.getValue(MSysConfig.APPLICATION_IMPLEMENTATION_VENDOR, null);

String version =
MSysConfig.getValue(MSysConfig.APPLICATION_MAIN_VERSION, null);


isVersionShown()  要顯示版本
MSysConfig.getBooleanValue(MSysConfig.APPLICATION_MAIN_VERSION_SHOWN, true);

isDBVersionShown()  要顯示資料庫版本
MSysConfig.getBooleanValue(MSysConfig.APPLICATION_DATABASE_VERSION_SHOWN, defaultVal);

isVendorShown()  要顯示供應商
MSysConfig.getBooleanValue(MSysConfig.APPLICATION_IMPLEMENTATION_VENDOR_SHOWN, true);

isJVMShown()  要顯示 Java 版次 MSysConfig.getBooleanValue(MSysConfig.APPLICATION_JVM_VERSION_SHOWN, defaultVal);

isOSShown()  要顯示 OS
MSysConfig.getBooleanValue(MSysConfig.APPLICATION_OS_INFO_SHOWN, defaultVal);

isHostShown()   要顯示 Host主機MSysConfig.getBooleanValue(MSysConfig.APPLICATION_HOST_SHOWN, defaultVal);

2015年3月27日 星期五

iDempiere 複製 Oracle EBS 報表

CREATE OR REPLACE PROCEDURE IDEMPIERE.Printformat_Copy
(
    PInstance_ID            IN NUMBER
)
AS
/*
DECLARE
  PINSTANCE_ID NUMBER;

BEGIN
  PINSTANCE_ID := 0;
  IDEMPIERE.PRINTFORMAT_COPY ( PINSTANCE_ID );
  COMMIT;
END;
*/
    --    Logistics
    ResultStr                        VARCHAR2(2000);
    Message                            VARCHAR2(2000);
    Record_ID                        NUMBER;
    IsProcessing                    CHAR(1);
    IsProcessed                        CHAR(1);
    myResult                        NUMBER := 1;    --    Success
    --    Parameter
    CURSOR Cur_Parameter (PInstance NUMBER) IS
        SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
          FROM AD_PInstance i, AD_PInstance_Para p
         WHERE i.AD_PInstance_ID=PInstance
           AND i.AD_PInstance_ID=p.AD_PInstance_ID(+)
         ORDER BY p.SeqNo;
-- DESC AD_Printformat
-- DESC AD_PrintformatItem
  --SELECT Name,AD_Printformat_ID FROM AD_Printformat WHERE Name LIKE '%Order%';
  --Order Detail    1000031
  --Order Header    118
  --Order LineTax   119
  --Order Header1000088    1000088
  --Order LineTax1000089    1000089
  --Order Detail1000090    1000090
  -- SELECT Name,AD_Printformat_ID FROM AD_PrintformatItem WHERE AD_Printformat_ID  IN(1000088,1000089,1000090)
   
     CURSOR    Cur_Head   IS
        SELECT Name,AD_Printformat_ID
          FROM AD_Printformat
         WHERE Name IN ('Order Header','Order Detail','Order LineTax');
       
     CURSOR    Cur_AD_Printformat_Trl (x_AD_Printformat_ID NUMBER)    IS
        SELECT
          AD_PRINTFORMAT_ID      ,--NUMBER(10)             DEFAULT 0                     NOT NULL,
          AD_LANGUAGE            ,--VARCHAR2(6 BYTE)       NOT NULL,
          AD_CLIENT_ID           ,--NUMBER(10)             NOT NULL,
          AD_ORG_ID              ,--NUMBER(10)             NOT NULL,
          ISACTIVE               ,--CHAR(1 BYTE)           DEFAULT 'Y'                   NOT NULL,
          CREATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          CREATEDBY              ,--NUMBER(10)             NOT NULL,
          UPDATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY              ,--NUMBER(10)             NOT NULL,
          NAME                   ,--VARCHAR2(60 BYTE)      NOT NULL,
          DESCRIPTION            ,--VARCHAR2(255 BYTE)     DEFAULT NULL,
          ISTRANSLATED           ,--CHAR(1 BYTE)           NOT NULL,
          AD_PRINTFORMAT_TRL_UU   --VARCHAR2(36 BYTE)      DEFAULT NULL
     FROM AD_Printformat_Trl
    WHERE AD_Printformat_ID=x_AD_Printformat_ID;
   
     -- DESC AD_Printformat_Trl
     CURSOR    Cur_AD_Printformat (x_AD_Printformat_ID NUMBER)    IS
        SELECT
          AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          CREATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          CREATEDBY               ,--NUMBER(10)            NOT NULL,
          UPDATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          NAME                    ,--NVARCHAR2(60)         NOT NULL,
          DESCRIPTION             ,--NVARCHAR2(255),
          ISTABLEBASED            ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISFORM                  ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          AD_TABLE_ID             ,--NUMBER(10)            NOT NULL,
          AD_PRINTPAPER_ID        ,--NUMBER(10)            NOT NULL,
          AD_PRINTCOLOR_ID        ,--NUMBER(10)            NOT NULL,
          AD_PRINTFONT_ID         ,--NUMBER(10)            NOT NULL,
          ISSTANDARDHEADERFOOTER  ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          HEADERMARGIN            ,--NUMBER(10)            NOT NULL,
          FOOTERMARGIN            ,--NUMBER(10)            NOT NULL,
          CREATECOPY              ,--CHAR(1 BYTE),
          AD_REPORTVIEW_ID        ,--NUMBER(10),
          AD_PRINTTABLEFORMAT_ID  ,--NUMBER(10),
          PRINTERNAME             ,--NVARCHAR2(40),
          ISDEFAULT               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          JASPERPROCESS_ID        ,--NUMBER(10),
          CLASSNAME               ,--VARCHAR2(240 BYTE),
          ARGS                    ,--VARCHAR2(480 BYTE),
          AD_PRINTFORMAT_UU       ,--NVARCHAR2(36)         DEFAULT NULL,
          AD_WINDOW_ID             --NUMBER(10)            DEFAULT NULL
     FROM AD_Printformat
    WHERE AD_Printformat_ID=x_AD_Printformat_ID;

--DESC AD_PrintformatItem_Trl
     CURSOR    Cur_AD_PrintformatItem (x_AD_Printformat_ID NUMBER)    IS
        SELECT
          AD_PRINTFORMATITEM_ID   ,--NUMBER(10)            NOT NULL,
          AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          CREATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          CREATEDBY               ,--NUMBER(10)            NOT NULL,
          UPDATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          NAME                    ,--NVARCHAR2(60)         NOT NULL,
          PRINTNAME               ,--NVARCHAR2(2000),
          ISPRINTED               ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          PRINTAREATYPE           ,--CHAR(1 BYTE)          NOT NULL,
          SEQNO                   ,--NUMBER(10)            NOT NULL,
          PRINTFORMATTYPE         ,--CHAR(1 BYTE)          NOT NULL,
          AD_COLUMN_ID            ,--NUMBER(10),
          AD_PRINTFORMATCHILD_ID  ,--NUMBER(10),
          ISRELATIVEPOSITION      ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISNEXTLINE              ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          XSPACE                  ,--NUMBER(10)            NOT NULL,
          YSPACE                  ,--NUMBER(10)            NOT NULL,
          XPOSITION               ,--NUMBER(10)            NOT NULL,
          YPOSITION               ,--NUMBER(10)            NOT NULL,
          MAXWIDTH                ,--NUMBER(10)            NOT NULL,
          ISHEIGHTONELINE         ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          MAXHEIGHT               ,--NUMBER(10)            NOT NULL,
          FIELDALIGNMENTTYPE      ,--CHAR(1 BYTE)          NOT NULL,
          LINEALIGNMENTTYPE       ,--CHAR(1 BYTE)          NOT NULL,
          AD_PRINTCOLOR_ID        ,--NUMBER(10),
          AD_PRINTFONT_ID         ,--NUMBER(10),
          ISORDERBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          SORTNO                  ,--NUMBER(10)            NOT NULL,
          ISGROUPBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISPAGEBREAK             ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSUMMARIZED            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          IMAGEISATTACHED         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          IMAGEURL                ,--NVARCHAR2(120),
          ISAVERAGED              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISCOUNTED               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSETNLPOSITION         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSUPPRESSNULL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          BELOWCOLUMN             ,--NUMBER(10),
          AD_PRINTGRAPH_ID        ,--NUMBER(10),
          ISFIXEDWIDTH            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISNEXTPAGE              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          PRINTNAMESUFFIX         ,--NVARCHAR2(60),
          ISMINCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISMAXCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISRUNNINGTOTAL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          RUNNINGTOTALLINES       ,--NUMBER(10),
          ISVARIANCECALC          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISDEVIATIONCALC         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISFILLEDRECTANGLE       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          LINEWIDTH               ,--NUMBER(10),
          ARCDIAMETER             ,--NUMBER(10),
          SHAPETYPE               ,--CHAR(1 BYTE),
          ISCENTRALLYMAINTAINED   ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISIMAGEFIELD            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          BARCODETYPE             ,--CHAR(3 BYTE),
          FORMATPATTERN           ,--NVARCHAR2(60)         DEFAULT NULL,
          ISSUPPRESSREPEATS       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          AD_PRINTFORMATITEM_UU   ,--NVARCHAR2(36)         DEFAULT NULL,
          ISDESC                   --CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL
     FROM AD_PrintformatItem
    WHERE AD_Printformat_ID=x_AD_Printformat_ID;
   
   
     CURSOR    Cur_AD_PrintformatItem_Trl (x_AD_PrintformatItem_ID NUMBER)    IS
        SELECT
          AD_PRINTFORMATITEM_ID      ,--NUMBER(10)         NOT NULL,
          AD_LANGUAGE                ,--VARCHAR2(6 BYTE)   NOT NULL,
          AD_CLIENT_ID               ,--NUMBER(10)         NOT NULL,
          AD_ORG_ID                  ,--NUMBER(10)         NOT NULL,
          ISACTIVE                   ,--CHAR(1 BYTE)       DEFAULT 'Y'                   NOT NULL,
          CREATED                    ,--DATE               DEFAULT SYSDATE               NOT NULL,
          CREATEDBY                  ,--NUMBER(10)         NOT NULL,
          UPDATED                    ,--DATE               DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY                  ,--NUMBER(10)         NOT NULL,
          PRINTNAME                  ,--NVARCHAR2(2000),
          ISTRANSLATED               ,--CHAR(1 BYTE)       DEFAULT 'N'                   NOT NULL,
          PRINTNAMESUFFIX            ,--NVARCHAR2(60),
          AD_PRINTFORMATITEM_TRL_UU  ,--NVARCHAR2(36)      DEFAULT NULL,
          NAME                        --NVARCHAR2(60)      DEFAULT NULL                  NOT NULL
     FROM AD_PrintformatItem_Trl
    WHERE AD_PrintformatItem_ID=x_AD_PrintformatItem_ID;
   
      --
    Updated                            NUMBER := 0;
    Created                            NUMBER := 0;
    Updated_Total                    NUMBER := 0;
    Created_Total                    NUMBER := 0;
    v_H_ID                          NUMBER(10,0) := 0;
    v_H_UU                          VARCHAR2(36) := NULL;
    v_HT_ID                         NUMBER(10,0) := 0;
    v_HT_UU                         VARCHAR2(36) := NULL;
    v_I_ID                          NUMBER(10,0) := 0;
    v_I_UU                          VARCHAR2(36) := NULL;
    v_IT_ID                         NUMBER(10,0) := 0;
    v_IT_UU                         VARCHAR2(36) := NULL;
    p_AD_Printformat_ID             NUMBER(10,0) := 0;
    P_Printformat_ID                NUMBER(10,0) := 0;
BEGIN
    --  Update AD_PInstance
    DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || PInstance_ID);
    ResultStr := 'PInstanceNotFound';
    UPDATE AD_PInstance
       SET Created = SysDate,
           IsProcessing = 'Y'
     WHERE AD_PInstance_ID=PInstance_ID;
    COMMIT;

    DBMS_OUTPUT.PUT_LINE('ReadingParameters');
    ResultStr := 'ReadingParameters';
    FOR p IN Cur_Parameter (PInstance_ID) LOOP
        Record_ID := p.Record_ID;
    /* IF (p.ParameterName = 'C_BP_Group_ID') THEN
             C_BP_Group_ID := p.P_Number;
            DBMS_OUTPUT.PUT_LINE('  C_BP_Group_ID=' || C_BP_Group_ID);
        ELSE
            DBMS_OUTPUT.PUT_LINE('*** Unknown Parameter=' || p.ParameterName);
         END IF;
   */
    END LOOP;    --    Get Parameter
    DBMS_OUTPUT.PUT_LINE('  Record_ID=' || Record_ID);

  --SELECT Name,AD_Printformat_ID FROM AD_Printformat WHERE Name LIKE '%Order%';
  --Order Detail    1000031
  --Order Header    118
  --Order LineTax   119
 
    p_AD_Printformat_ID := 0;
    /**
     *    For all Accounting Schema of the Group
     */
    DBMS_OUTPUT.PUT_LINE('Cur_Head');
    FOR p IN Cur_Head LOOP

    DBMS_OUTPUT.PUT_LINE('Cur_AD_Printformat');
    FOR a IN Cur_AD_Printformat (p.AD_Printformat_ID) LOOP
         
        --  SELECT * FROM AD_Sequence WHERE NAME='AD_PrintFormat'        --579
        --  SELECT * FROM AD_Sequence WHERE NAME='AD_PrintFormat_Trl'    --200177
        --  SELECT * FROM AD_Sequence WHERE NAME='AD_PrintFormatItem'    --575
        --  SELECT * FROM AD_Sequence WHERE NAME='AD_PrintFormatItem_Trl'--618
       
          SELECT generate_uuid                           INTO v_H_UU FROM DUAL;
          SELECT NEXTIDFUNCBYNAME('AD_PrintFormat', 'N') INTO v_H_ID FROM DUAL;
         
          DBMS_OUTPUT.PUT_LINE('Cur_AD_Printformat v_H_ID='||v_H_ID||' ,v_H_UU='||v_H_UU);
         
          INSERT INTO AD_Printformat(
          AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          CREATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          CREATEDBY               ,--NUMBER(10)            NOT NULL,
          UPDATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          NAME                    ,--NVARCHAR2(60)         NOT NULL,
          DESCRIPTION             ,--NVARCHAR2(255),
          ISTABLEBASED            ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISFORM                  ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          AD_TABLE_ID             ,--NUMBER(10)            NOT NULL,
          AD_PRINTPAPER_ID        ,--NUMBER(10)            NOT NULL,
          AD_PRINTCOLOR_ID        ,--NUMBER(10)            NOT NULL,
          AD_PRINTFONT_ID         ,--NUMBER(10)            NOT NULL,
          ISSTANDARDHEADERFOOTER  ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          HEADERMARGIN            ,--NUMBER(10)            NOT NULL,
          FOOTERMARGIN            ,--NUMBER(10)            NOT NULL,
          CREATECOPY              ,--CHAR(1 BYTE),
          AD_REPORTVIEW_ID        ,--NUMBER(10),
          AD_PRINTTABLEFORMAT_ID  ,--NUMBER(10),
          PRINTERNAME             ,--NVARCHAR2(40),
          ISDEFAULT               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          JASPERPROCESS_ID        ,--NUMBER(10),
          CLASSNAME               ,--VARCHAR2(240 BYTE),
          ARGS                    ,--VARCHAR2(480 BYTE),
          AD_PRINTFORMAT_UU       ,--NVARCHAR2(36)         DEFAULT NULL,
          AD_WINDOW_ID             --NUMBER(10)            DEFAULT NULL
          )VALUES(
          v_H_ID,--a.AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          a.AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          a.AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          a.ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          SYSDATE,--a.CREATED       ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          a.CREATEDBY               ,--NUMBER(10)            NOT NULL,
          SYSDATE,--a.UPDATED       ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          a.UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          a.NAME||v_H_ID            ,--NVARCHAR2(60)         NOT NULL,
          a.DESCRIPTION             ,--NVARCHAR2(255),
          a.ISTABLEBASED            ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          a.ISFORM                  ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          a.AD_TABLE_ID             ,--NUMBER(10)            NOT NULL,
          a.AD_PRINTPAPER_ID        ,--NUMBER(10)            NOT NULL,
          a.AD_PRINTCOLOR_ID        ,--NUMBER(10)            NOT NULL,
          a.AD_PRINTFONT_ID         ,--NUMBER(10)            NOT NULL,
          a.ISSTANDARDHEADERFOOTER  ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          a.HEADERMARGIN            ,--NUMBER(10)            NOT NULL,
          a.FOOTERMARGIN            ,--NUMBER(10)            NOT NULL,
          a.CREATECOPY              ,--CHAR(1 BYTE),
          a.AD_REPORTVIEW_ID        ,--NUMBER(10),
          a.AD_PRINTTABLEFORMAT_ID  ,--NUMBER(10),
          a.PRINTERNAME             ,--NVARCHAR2(40),
          a.ISDEFAULT               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          a.JASPERPROCESS_ID        ,--NUMBER(10),
          a.CLASSNAME               ,--VARCHAR2(240 BYTE),
          a.ARGS                    ,--VARCHAR2(480 BYTE),
          v_H_UU,--a.AD_PRINTFORMAT_UU       ,--NVARCHAR2(36)         DEFAULT NULL,
          a.AD_WINDOW_ID             --NUMBER(10)            DEFAULT NULL
          );
         
       DBMS_OUTPUT.PUT_LINE('Cur_AD_Printformat_Trl');
       FOR b IN Cur_AD_Printformat_Trl (a.AD_Printformat_ID) LOOP
      
          SELECT generate_uuid                               INTO v_HT_UU FROM DUAL;
          SELECT NEXTIDFUNCBYNAME('AD_PrintFormat_Trl', 'N') INTO v_HT_ID FROM DUAL;
         
          --ALTER TABLE AD_Printformat_Trl ADD AD_PRINTFORMAT_TRL_ID NUMBER(10);
         
          INSERT INTO AD_Printformat_Trl(
          AD_PRINTFORMAT_TRL_ID  ,--NUMBER(10)
          AD_PRINTFORMAT_ID      ,--NUMBER(10)             DEFAULT 0                     NOT NULL,
          AD_LANGUAGE            ,--VARCHAR2(6 BYTE)       NOT NULL,
          AD_CLIENT_ID           ,--NUMBER(10)             NOT NULL,
          AD_ORG_ID              ,--NUMBER(10)             NOT NULL,
          ISACTIVE               ,--CHAR(1 BYTE)           DEFAULT 'Y'                   NOT NULL,
          CREATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          CREATEDBY              ,--NUMBER(10)             NOT NULL,
          UPDATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY              ,--NUMBER(10)             NOT NULL,
          NAME                   ,--VARCHAR2(60 BYTE)      NOT NULL,
          DESCRIPTION            ,--VARCHAR2(255 BYTE)     DEFAULT NULL,
          ISTRANSLATED           ,--CHAR(1 BYTE)           NOT NULL,
          AD_PRINTFORMAT_TRL_UU   --VARCHAR
          )VALUES(
          v_HT_ID, --b.AD_PRINTFORMAT_TRL_ID      ,--NUMBER(10
          v_H_ID,  --b.AD_PRINTFORMAT_ID          ,--NUMBER(10)             DEFAULT 0                     NOT NULL,
          b.AD_LANGUAGE            ,--VARCHAR2(6 BYTE)       NOT NULL,
          b.AD_CLIENT_ID           ,--NUMBER(10)             NOT NULL,
          b.AD_ORG_ID              ,--NUMBER(10)             NOT NULL,
          b.ISACTIVE               ,--CHAR(1 BYTE)           DEFAULT 'Y'                   NOT NULL,
          SYSDATE,--b.CREATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          b.CREATEDBY              ,--NUMBER(10)             NOT NULL,
          SYSDATE,--b.UPDATED                ,--DATE                   DEFAULT SYSDATE               NOT NULL,
          b.UPDATEDBY              ,--NUMBER(10)             NOT NULL,
          b.NAME                   ,--VARCHAR2(60 BYTE)      NOT NULL,
          b.DESCRIPTION            ,--VARCHAR2(255 BYTE)     DEFAULT NULL,
          b.ISTRANSLATED           ,--CHAR(1 BYTE)           NOT NULL,
          v_HT_UU --b.AD_PRINTFORMAT_TRL_UU   --VARCHAR
          );
       END LOOP;
      
       DBMS_OUTPUT.PUT_LINE('Cur_AD_PrintformatItem');
       FOR c IN Cur_AD_PrintformatItem (a.AD_Printformat_ID) LOOP

          SELECT generate_uuid                               INTO v_I_UU FROM DUAL;
          SELECT NEXTIDFUNCBYNAME('AD_PrintFormatItem', 'N') INTO v_I_ID FROM DUAL;
         
          INSERT INTO AD_PrintformatItem(
          AD_PRINTFORMATITEM_ID   ,--NUMBER(10)            NOT NULL,
          AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          CREATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          CREATEDBY               ,--NUMBER(10)            NOT NULL,
          UPDATED                 ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          NAME                    ,--NVARCHAR2(60)         NOT NULL,
          PRINTNAME               ,--NVARCHAR2(2000),
          ISPRINTED               ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          PRINTAREATYPE           ,--CHAR(1 BYTE)          NOT NULL,
          SEQNO                   ,--NUMBER(10)            NOT NULL,
          PRINTFORMATTYPE         ,--CHAR(1 BYTE)          NOT NULL,
          AD_COLUMN_ID            ,--NUMBER(10),
          AD_PRINTFORMATCHILD_ID  ,--NUMBER(10),
          ISRELATIVEPOSITION      ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISNEXTLINE              ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          XSPACE                  ,--NUMBER(10)            NOT NULL,
          YSPACE                  ,--NUMBER(10)            NOT NULL,
          XPOSITION               ,--NUMBER(10)            NOT NULL,
          YPOSITION               ,--NUMBER(10)            NOT NULL,
          MAXWIDTH                ,--NUMBER(10)            NOT NULL,
          ISHEIGHTONELINE         ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          MAXHEIGHT               ,--NUMBER(10)            NOT NULL,
          FIELDALIGNMENTTYPE      ,--CHAR(1 BYTE)          NOT NULL,
          LINEALIGNMENTTYPE       ,--CHAR(1 BYTE)          NOT NULL,
          AD_PRINTCOLOR_ID        ,--NUMBER(10),
          AD_PRINTFONT_ID         ,--NUMBER(10),
          ISORDERBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          SORTNO                  ,--NUMBER(10)            NOT NULL,
          ISGROUPBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISPAGEBREAK             ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSUMMARIZED            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          IMAGEISATTACHED         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          IMAGEURL                ,--NVARCHAR2(120),
          ISAVERAGED              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISCOUNTED               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSETNLPOSITION         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISSUPPRESSNULL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          BELOWCOLUMN             ,--NUMBER(10),
          AD_PRINTGRAPH_ID        ,--NUMBER(10),
          ISFIXEDWIDTH            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISNEXTPAGE              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          PRINTNAMESUFFIX         ,--NVARCHAR2(60),
          ISMINCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISMAXCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISRUNNINGTOTAL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          RUNNINGTOTALLINES       ,--NUMBER(10),
          ISVARIANCECALC          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISDEVIATIONCALC         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          ISFILLEDRECTANGLE       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          LINEWIDTH               ,--NUMBER(10),
          ARCDIAMETER             ,--NUMBER(10),
          SHAPETYPE               ,--CHAR(1 BYTE),
          ISCENTRALLYMAINTAINED   ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          ISIMAGEFIELD            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          BARCODETYPE             ,--CHAR(3 BYTE),
          FORMATPATTERN           ,--NVARCHAR2(60)         DEFAULT NULL,
          ISSUPPRESSREPEATS       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          AD_PRINTFORMATITEM_UU   ,--NVARCHAR2(36)         DEFAULT NULL,
          ISDESC                   --CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL
          )VALUES(
          v_I_ID, --c.AD_PRINTFORMATITEM_ID   ,--NUMBER(10)            NOT NULL,
          c.AD_CLIENT_ID            ,--NUMBER(10)            NOT NULL,
          c.AD_ORG_ID               ,--NUMBER(10)            NOT NULL,
          c.ISACTIVE                ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          SYSDATE, --c.CREATED      ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          c.CREATEDBY               ,--NUMBER(10)            NOT NULL,
          SYSDATE, --c.UPDATED      ,--DATE                  DEFAULT SYSDATE               NOT NULL,
          c.UPDATEDBY               ,--NUMBER(10)            NOT NULL,
          v_H_ID, --c.AD_PRINTFORMAT_ID       ,--NUMBER(10)            NOT NULL,
          c.NAME                    ,--NVARCHAR2(60)         NOT NULL,
          c.PRINTNAME               ,--NVARCHAR2(2000),
          c.ISPRINTED               ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          c.PRINTAREATYPE           ,--CHAR(1 BYTE)          NOT NULL,
          c.SEQNO                   ,--NUMBER(10)            NOT NULL,
          c.PRINTFORMATTYPE         ,--CHAR(1 BYTE)          NOT NULL,
          c.AD_COLUMN_ID            ,--NUMBER(10),
          c.AD_PRINTFORMATCHILD_ID  ,--NUMBER(10),
          c.ISRELATIVEPOSITION      ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          c.ISNEXTLINE              ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          c.XSPACE                  ,--NUMBER(10)            NOT NULL,
          c.YSPACE                  ,--NUMBER(10)            NOT NULL,
          c.XPOSITION               ,--NUMBER(10)            NOT NULL,
          c.YPOSITION               ,--NUMBER(10)            NOT NULL,
          c.MAXWIDTH                ,--NUMBER(10)            NOT NULL,
          c.ISHEIGHTONELINE         ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          c.MAXHEIGHT               ,--NUMBER(10)            NOT NULL,
          c.FIELDALIGNMENTTYPE      ,--CHAR(1 BYTE)          NOT NULL,
          c.LINEALIGNMENTTYPE       ,--CHAR(1 BYTE)          NOT NULL,
          c.AD_PRINTCOLOR_ID        ,--NUMBER(10),
          c.AD_PRINTFONT_ID         ,--NUMBER(10),
          c.ISORDERBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.SORTNO                  ,--NUMBER(10)            NOT NULL,
          c.ISGROUPBY               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISPAGEBREAK             ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISSUMMARIZED            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.IMAGEISATTACHED         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.IMAGEURL                ,--NVARCHAR2(120),
          c.ISAVERAGED              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISCOUNTED               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISSETNLPOSITION         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISSUPPRESSNULL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.BELOWCOLUMN             ,--NUMBER(10),
          c.AD_PRINTGRAPH_ID        ,--NUMBER(10),
          c.ISFIXEDWIDTH            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISNEXTPAGE              ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.PRINTNAMESUFFIX         ,--NVARCHAR2(60),
          c.ISMINCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISMAXCALC               ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISRUNNINGTOTAL          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.RUNNINGTOTALLINES       ,--NUMBER(10),
          c.ISVARIANCECALC          ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISDEVIATIONCALC         ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.ISFILLEDRECTANGLE       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.LINEWIDTH               ,--NUMBER(10),
          c.ARCDIAMETER             ,--NUMBER(10),
          c.SHAPETYPE               ,--CHAR(1 BYTE),
          c.ISCENTRALLYMAINTAINED   ,--CHAR(1 BYTE)          DEFAULT 'Y'                   NOT NULL,
          c.ISIMAGEFIELD            ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          c.BARCODETYPE             ,--CHAR(3 BYTE),
          c.FORMATPATTERN           ,--NVARCHAR2(60)         DEFAULT NULL,
          c.ISSUPPRESSREPEATS       ,--CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL,
          v_I_UU, --c.AD_PRINTFORMATITEM_UU   ,--NVARCHAR2(36)         DEFAULT NULL,
          c.ISDESC                   --CHAR(1 BYTE)          DEFAULT 'N'                   NOT NULL
          );

          DBMS_OUTPUT.PUT_LINE('Cur_AD_PrintformatItem_Trl');
          FOR d IN Cur_AD_PrintformatItem_Trl (c.AD_PrintformatItem_ID) LOOP
         
          SELECT generate_uuid                                   INTO v_IT_UU FROM DUAL;
          SELECT NEXTIDFUNCBYNAME('AD_PrintFormatItem_Trl', 'N') INTO v_IT_ID FROM DUAL;
         
          --ALTER TABLE AD_PrintformatItem_Trl ADD AD_PRINTFORMATITEM_TRL_ID   NUMBER(10)
          INSERT INTO AD_PrintformatItem_Trl(
          AD_PRINTFORMATITEM_TRL_ID  ,--NUMBER(10),
          AD_PRINTFORMATITEM_ID      ,--NUMBER(10)         NOT NULL,
          AD_LANGUAGE                ,--VARCHAR2(6 BYTE)   NOT NULL,
          AD_CLIENT_ID               ,--NUMBER(10)         NOT NULL,
          AD_ORG_ID                  ,--NUMBER(10)         NOT NULL,
          ISACTIVE                   ,--CHAR(1 BYTE)       DEFAULT 'Y'                   NOT NULL,
          CREATED                    ,--DATE               DEFAULT SYSDATE               NOT NULL,
          CREATEDBY                  ,--NUMBER(10)         NOT NULL,
          UPDATED                    ,--DATE               DEFAULT SYSDATE               NOT NULL,
          UPDATEDBY                  ,--NUMBER(10)         NOT NULL,
          PRINTNAME                  ,--NVARCHAR2(2000),
          ISTRANSLATED               ,--CHAR(1 BYTE)       DEFAULT 'N'                   NOT NULL,
          PRINTNAMESUFFIX            ,--NVARCHAR2(60),
          AD_PRINTFORMATITEM_TRL_UU  ,--NVARCHAR2(36)      DEFAULT NULL,
          NAME                        --NVARCHAR2(60)      DEFAULT NULL                  NOT NULL
          )VALUES(
          v_IT_ID, --d.AD_PRINTFORMATITEM_TRL_ID      ,--NUMBER(10)         NOT NULL,
          v_I_ID,  --d.AD_PRINTFORMATITEM_ID          ,--NUMBER(10)         NOT NULL,
          d.AD_LANGUAGE                ,--VARCHAR2(6 BYTE)   NOT NULL,
          d.AD_CLIENT_ID               ,--NUMBER(10)         NOT NULL,
          d.AD_ORG_ID                  ,--NUMBER(10)         NOT NULL,
          d.ISACTIVE                   ,--CHAR(1 BYTE)       DEFAULT 'Y'                   NOT NULL,
          SYSDATE, --d.CREATED         ,--DATE               DEFAULT SYSDATE               NOT NULL,
          d.CREATEDBY                  ,--NUMBER(10)         NOT NULL,
          SYSDATE, --d.UPDATED         ,--DATE               DEFAULT SYSDATE               NOT NULL,
          d.UPDATEDBY                  ,--NUMBER(10)         NOT NULL,
          d.PRINTNAME                  ,--NVARCHAR2(2000),
          d.ISTRANSLATED               ,--CHAR(1 BYTE)       DEFAULT 'N'                   NOT NULL,
          d.PRINTNAMESUFFIX            ,--NVARCHAR2(60),
          v_IT_UU, --d.AD_PRINTFORMATITEM_TRL_UU  ,--NVARCHAR2(36)      DEFAULT NULL,
          d.NAME                        --NVARCHAR2(60)      DEFAULT NULL                  NOT NULL
          );
          END LOOP;
       END LOOP;
   
    END LOOP; --PrintFormat
    END LOOP; --Parameter
       
    --    Created := SQL%ROWCOUNT;
    --    DBMS_OUTPUT.PUT_LINE('Customers = ' || Updated || ' / ' || Created);
    Message := '@Created@=' || Created_Total || ':2, @Updated@=' || Updated_Total || ':2';


<<FINISH_PROCESS>>
    --  Update AD_PInstance
    DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished - ' || Message);
    UPDATE  AD_PInstance
    SET Updated = SysDate,
        IsProcessing = 'N',
        Result = myResult,                 -- 1=Success
        ErrorMsg = Message
    WHERE   AD_PInstance_ID=PInstance_ID;
    COMMIT;
    RETURN;

EXCEPTION
    WHEN  OTHERS THEN
        ResultStr := ResultStr || ': ' || SQLERRM || ' - ' || Message;
        DBMS_OUTPUT.PUT_LINE(ResultStr);
        UPDATE  AD_PInstance
        SET Updated = SysDate,
            IsProcessing = 'N',
            Result = 0,             -- failure
            ErrorMsg = ResultStr
        WHERE   AD_PInstance_ID=PInstance_ID;
        COMMIT;
        RETURN;

END Printformat_Copy;
/