Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Code listing for: ZFILETOIDOCFACT
Description: File to Idoc Program

---&--------------------------------------------------------------------
*& Report ZFILETOIDOCFACT
*&
&---------------------------------------------------------------------
----------------------------------------------------------------------

  • PROGRAM DESCRIPTION: File to Inbound Idoc Program.
    *
  • DEVELOPER: Aveek Ghose
  • CREATION DATE: 2008-04-18
  • RDD NUMBER: DCDD027
  • TRANSPORT NUMBER(S): RD2K902769
    *
      • REVISION HISTORY --------------------------------------------------*
        *
  • DEVELOPER:
  • DATE APPLIED: YYYY-MM-DD
  • SCR NUMBER:
  • RDD NUMBER:
  • TRANSPORT NUMBER(S):
  • DESCRIPTION:
    *
    ----------------------------------------------------------------------

REPORT ZFILETOIDOCFACT
NO STANDARD PAGE HEADING
LINE-SIZE 150
LINE-COUNT 55
MESSAGE-ID ZFACTGLB. "/factglb/gta_custdev.

  • Include for Global Data Declaration
  • INCLUDE ZFACTGLB_GTDMI_VARTAB_TOP.
  • Include for Selection Screen
  • INCLUDE ZFACTGLB_GTDMI_VARTAB_SEL.
  • Include for Sub Routines
  • INCLUDE ZFACTGLB_GTDMI_VARTAB_FORMS.

************************************************************************

  • TYPE POOLS
    ************************************************************************
    *Type declaration for ALV display

TYPE-POOLS : slis.
Include .
type-pools: col, "#EC *
icon, "#EC *
sym. "#EC *

  • Target structure definitions

tables:
E1CUVTM,
E1DATEM,
E1CUV1M,
edp21, "#EC NEEDED
edi_dc40,
edi_dd40,
edi_ds40. "#EC NEEDED

************************************************************************

  • GLOBAL TYPES
    ************************************************************************

TYPES : BEGIN OF ty_vartab.
include structure E1CUVTM.
TYPES: END OF ty_vartab.

TYPES : BEGIN OF ty_vartabdate.
INCLUDE STRUCTURE E1DATEM.
TYPES : END OF ty_vartabdate.

*Structure for data retreived
TYPES : BEGIN OF ty_vardetails.
INCLUDE STRUCTURE E1CUV1M.
TYPES : END OF ty_vardetails.

*Structure for data retreived from table tabinput.
TYPES : BEGIN OF ty_tabinput,
lines type string,
END OF ty_tabinput.

*Structure for data retreived from Table dsn_input.
TYPES : BEGIN OF ty_dsninput, "#EC *
LINE(101) type c,
END OF ty_dsninput.

*Structure for data retreived from Table dsn_input.
TYPES : BEGIN OF ty_newinput, "#EC *
LINE(101) type c,
flag(1) type c,
END OF ty_newinput.

*Structure for keeping the values of all the custom tables
TYPES : BEGIN OF ty_custom_tabs,
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "Plant
lgort TYPE lgort_d, "Storage Location
qunty TYPE P DECIMALS 2, "Standard Order Quantity
det_loc TYPE CHAR6, "Detail Location
class TYPE CHAR2, "Class
rate TYPE P DECIMALS 2, "Rate
END OF ty_custom_tabs.

*Type declared for the internal table and work area which will store
*fields for error log
TYPES : BEGIN OF ty_error_log,
matnr TYPE matnr, "Material Number
mtart TYPE mtart, "Material Type
sel_data TYPE char10, "No of selectyed data
END OF ty_error_log.

*Structure for keeping the output data
TYPES : BEGIN OF ty_final,
VTNAM(018) type C,
CHAR1(030) type C,
CHAR2(030) type C,
CHAR3(030) type C,
CHAR4(030) type C,
CHAR5(030) type C,
CHAR6(030) type C,
CHAR7(030) type C,
CHAR8(030) type C,
CHAR9(030) type C,
CHAR10(030) type C,
CHAR11(030) type C,
CHAR12(030) type C,
CHAR13(030) type C,
CHAR14(030) type C,
CHAR15(030) type C,
FLAG(001) type C,
END OF ty_final.

TYPES: begin of TY_CONTENTHD,
VTNAM(018) type C,
FLAG(001) type C,
end of TY_CONTENTHD.

TYPES: begin of TY_CONTENT,
VTNAM(018) type C,
CHAR1(030) type C,
CHAR2(030) type C,
CHAR3(030) type C,
CHAR4(030) type C,
CHAR5(030) type C,
CHAR6(030) type C,
CHAR7(030) type C,
CHAR8(030) type C,
CHAR9(030) type C,
CHAR10(030) type C,
CHAR11(030) type C,
CHAR12(030) type C,
CHAR13(030) type C,
CHAR14(030) type C,
CHAR15(030) type C,
FLAG(001) type C.
types: recnr_000001 type i.
types: recnr_000002 type i.

TYPES: end of TY_CONTENT.

TYPES: BEGIN OF TY_E1CUVTM,
MSGFN TYPE MSGFN,
VAR_TAB TYPE APITABL,
STATUS TYPE RCUTBST,
VTGROUP TYPE RCUTBGR,
AUTHSTRUC TYPE RCUTBBE,
AUTHENTRY TYPE RCUFNBI,
FLDELETE TYPE FLLKENZ,
DBTABNAME TYPE TABNAME16,
DBCONACTIVE TYPE DBCON_ACTI,
PRESDEC TYPE VTDCT,
END OF TY_E1CUVTM.

TYPES: BEGIN OF TY_E1CUV1M,
MSGFN TYPE MSGFN,
VTLINENO TYPE VTLINENO,
VTCHARACT TYPE ATNAM,
ATWRT TYPE ATWRT,
ATFLV TYPE ATFLV,
ATAWE TYPE MSEHI,
ATFLB TYPE ATFLB,
ATAW1 TYPE MSEHI,
ATCOD TYPE ATCOD,
ATTLV TYPE ATTLV,
ATTLB TYPE ATTLB,
ATPRZ TYPE ATPRZ,
ATINC TYPE ATINC,
VTLINENO5 TYPE VTLINENO5,
END OF TY_E1CUV1M.

TYPES: BEGIN OF TY_E1DATEM,
MSGFN TYPE MSGFN,
KEY_DATE TYPE SYDATUM,
AENNR TYPE AENNR,
EFFECTIVITY TYPE CC_MTEFF,
END OF TY_E1DATEM.

TYPES: BEGIN OF ty_vtnam,
vtint TYPE vtint, " Internal number of variant table
vtnam TYPE vtnam, " Name of variant table
error TYPE char1, " Indicates error in data format
reas TYPE char50, " Reason for failure
END OF ty_vtnam.

  • Get data type for characteristic
    TYPES: BEGIN OF ty_cabn,
    atinn TYPE atinn, "Internal characteristic
    atnam TYPE atnam, "Characteristic Name
    atfor TYPE atfor, "Data type of characteristic
    atson TYPE atson, "Indicator: Additional Values
    atprt TYPE atprt, "Check table
    atprr TYPE atprr, "Name of Check Report Program
    atprf TYPE atprf, "Function Module for Checking Values
    anzdz TYPE anzdz, "Number of Decimal Places
    check TYPE char1, "Indicates check required or not
    END OF ty_cabn.
  • Get field names of variant table
    TYPES: BEGIN OF ty_cuvtab_fld,
    vtint TYPE vtint, " Internal number of variant table
    atinn TYPE atinn, " Internal characteristic
    vtpos TYPE vtpos, " Item number of characteristic in variant
    exist TYPE char1, " X Indictaes characteristic is part of fil
    END OF ty_cuvtab_fld.
  • Store all data in internal table
    TYPES: BEGIN OF ty_file,
    vtnam TYPE vtnam,
    char1 TYPE atwrt,
    char2 TYPE atwrt,
    char3 TYPE atwrt,
    char4 TYPE atwrt,
    char5 TYPE atwrt,
    char6 TYPE atwrt,
    char7 TYPE atwrt,
    char8 TYPE atwrt,
    char9 TYPE atwrt,
    char10 TYPE atwrt,
    char11 TYPE atwrt,
    char12 TYPE atwrt,
    char13 TYPE atwrt,
    char14 TYPE atwrt,
    char15 TYPE atwrt,
    flag TYPE char1,
    error TYPE char50,
    END OF ty_file.
  • To check for duplicates
    TYPES: BEGIN OF ty_dupl,
    vtnam TYPE vtnam,
    char1 TYPE atwrt,
    char2 TYPE atwrt,
    char3 TYPE atwrt,
    char4 TYPE atwrt,
    char5 TYPE atwrt,
    char6 TYPE atwrt,
    char7 TYPE atwrt,
    char8 TYPE atwrt,
    char9 TYPE atwrt,
    char10 TYPE atwrt,
    char11 TYPE atwrt,
    char12 TYPE atwrt,
    char13 TYPE atwrt,
    char14 TYPE atwrt,
    char15 TYPE atwrt,
    slnid TYPE slnid,
    END OF ty_dupl.
  • Get previously loaded characteristic values for internal table (CHAR)
    TYPES: BEGIN OF ty_cuvtab_valc,
    vtint TYPE vtint, " Internal number of variant table
    slnid TYPE slnid, " Key for value combination in variant tab
    atinn TYPE atinn, " Internal characteristic
    valc TYPE atwrt, " Characteristic Value
    END OF ty_cuvtab_valc.
  • Get previously loaded characteristic values for internal table (NUM)
    TYPES: BEGIN OF ty_cuvtab_valn,
    vtint TYPE vtint, " Internal number of variant table
    slnid TYPE slnid, " Key for value combination in variant tab
    atinn TYPE atinn, " Internal characteristic
    val_from TYPE atflv, " Internal floating point from
    END OF ty_cuvtab_valn.
  • Store column positions of characteristics
    TYPES: BEGIN OF ty_col_pos,
    vtint TYPE vtint, " Internal number of variant table
    vtnam TYPE vtnam, " Variant table name
    atinn TYPE atinn, "Internal characteristic
    atnam TYPE atnam, "Characteristic Name
    field TYPE fieldname, "Field name
    req TYPE char1, " Required or not
    vtpos TYPE vtpos, " Item number of characteristics
    END OF ty_col_pos.
  • Store valid values for characteristics
    TYPES: BEGIN OF ty_cawn,
    atinn TYPE atinn, " Internal characteristic
    atzhl TYPE atzhl, " Int counter
    atwrt TYPE atwrt, " Characteristic Value
    atflv TYPE atflv, " Internal floating point from
    lkenz TYPE lkenz, " Deletion indicator
    END OF ty_cawn.
  • Store error messages for individual lines
    TYPES: BEGIN OF ty_error,
    vtnam TYPE vtnam, " Variant table name
    fname TYPE fieldname, " Fieldname
    atnam TYPE atnam, " Characteristic name
    atwrt TYPE atwrt, " Characteristic value
    row TYPE char5, " Row id
    END OF ty_error.
  • Begin TPR# 4618
  • To store unique number for variant
    TYPES: BEGIN OF ty_vnt_ma,
    vtnam TYPE vtnam,
  • unique_no TYPE /FACTGLB/GTDM_UNQN,
  • no_chr TYPE /FACTGLB/GTDM_NO_CHR,
    unique_no TYPE ZGTDM_UNQN,
    no_chr TYPE ZGTDM_NO_CHR,
    END OF ty_vnt_ma.
  • To find out concatenated number for
    TYPES: BEGIN OF ty_split,
    f1 TYPE char6,
    END OF ty_split.

TYPES: BEGIN OF ty_charval,
char TYPE char30,
END OF ty_charval.

TYPES:
TUMLS_MESSTYPE LIKE /SAPDMC/LSSCREEN-MESSTYPE,
TUMLS_MESSTYPETXT LIKE /SAPDMC/LSSCREEN-MESSTYPETXT,
TUMLS_MESSCODE LIKE EDK21-MESCOD.

TYPES:
TUMLS_TABNAME LIKE DFIES-TABNAME, "#EC NEEDED
TUMLS_SEGMENT LIKE DFIES-TABNAME. "#EC NEEDED

TYPES:
TUMLS_PATHFILE LIKE /SAPDMC/LSOINP-FILENAME, " alt
TUMLS_FILENAME LIKE /SAPDMC/LSOINP-FILENAME,
TUMLS_FILETEXT LIKE /SAPDMC/LSOINP-FILETEXT.

TYPES: "YOG141101
BEGIN OF type_errorline, "YOG141101
msgty LIKE sy-msgty, "YOG141101
id LIKE sy-msgid, "YOG141101
msgno LIKE sy-msgno, "YOG141101
par1 LIKE sy-msgv1, "YOG141101
par2 LIKE sy-msgv2, "YOG141101
par3 LIKE sy-msgv3, "YOG141101
par4 LIKE sy-msgv4, "YOG141101
END OF type_errorline. "YOG141101

TYPES:
type_errortab TYPE SORTED TABLE "YOG141101
OF type_errorline "YOG141101
WITH NON-UNIQUE KEY id msgno par1 par2 par3 par4.

***********************************************************************

  • GLOBAL INTERNAL TABLES
    ************************************************************************

DATA : i_newinput TYPE STANDARD TABLE OF ty_newinput. "#EC NEEDED
DATA : i_contentheader1 TYPE STANDARD TABLE OF ty_contenthd. "#EC NEEDED
DATA : i_contenttab1 TYPE STANDARD TABLE OF ty_content. "#EC NEEDED
DATA : i_contenttab2 TYPE STANDARD TABLE OF ty_content. "#EC NEEDED
DATA : i_contenttab3 TYPE STANDARD TABLE OF ty_content. "#EC NEEDED
DATA : i_E1CUV1M TYPE STANDARD TABLE OF E1CUV1M. "#EC NEEDED
DATA : i_errortab TYPE STANDARD TABLE OF solisti1. "#EC NEEDED

************************************************************************

  • GLOBAL WORK AREAS
    ************************************************************************

**Internal Table for the structure TY_T001L
DATA : wa_vartab TYPE ty_vartab. "#EC NEEDED
DATA : wa_vartabdate TYPE ty_vartabdate. "#EC NEEDED
DATA : wa_vardetails TYPE ty_vardetails. "#EC NEEDED
DATA : wa_tabinput TYPE ty_tabinput. "#EC NEEDED
DATA : wa_dsninput TYPE ty_dsninput. "#EC NEEDED
DATA : wa_newinput TYPE ty_newinput. "#EC NEEDED
DATA : wa_gnewinput TYPE ty_newinput. "#EC NEEDED
DATA : wa_ginput_data TYPE ty_newinput. "#EC NEEDED
DATA : wa_final TYPE ty_final. "#EC NEEDED
DATA : wa_content TYPE ty_content. "#EC NEEDED
DATA : wa_contenthd TYPE ty_contenthd. "#EC NEEDED
DATA : wa_contentheader type ty_contenthd. "#EC NEEDED
DATA : wa_contenttab TYPE ty_content. "#EC NEEDED
DATA : wa_content1 TYPE ty_content. "#EC NEEDED
DATA : wa_contenthd1 TYPE ty_contenthd. "#EC NEEDED
DATA : wa_contentheader1 type ty_contenthd. "#EC NEEDED
DATA : wa_contenttab1 TYPE ty_content. "#EC NEEDED
DATA : wa_contenttab2 TYPE ty_content. "#EC NEEDED
DATA : wa_E1CUVTM TYPE E1CUVTM. "#EC NEEDED
DATA : wa_E1CUV1M TYPE E1CUV1M. "#EC NEEDED
DATA : wa_E1DATEM TYPE E1DATEM. "#EC NEEDED
DATA : wa_error_tab TYPE solisti1. "#EC NEEDED

************************************************************************

  • INTERNAL TABLES AND WORK AREAS FOR BDC
    ************************************************************************

*Internal Table to store the data to display the error message
DATA : i_errormsg TYPE STANDARD TABLE OF solisti1."#EC NEEDED

*Internal Table to store the data to display the error message
DATA : i_error TYPE STANDARD TABLE OF solisti1. ."#EC NEEDED

**Work area to store the data to display the error message
DATA : wa_errormsg TYPE solisti1. "#EC NEEDED

**Internal table which will store data for the error log
DATA:i_error_log TYPE STANDARD TABLE OF ty_error_log. "#EC NEEDED

************************************************************************

  • GLOBAL VARIABLES
    ************************************************************************

DATA: G_FILE TYPE string. "#EC NEEDED
DATA : g_ctr_input_recs(5) type c. "#EC NEEDED
DATA: g_ctr_output_recs(5) type p. "#EC NEEDED
data : g_msg(100) type c. "#EC NEEDED
data: g_struct_file like g_file occurs 0. "#EC NEEDED
data: g_login type FILEINTERN. "#EC NEEDED
data: g_phyin type string. "#EC NEEDED
DATA: g_lprnt type RSPOPSHORT. "#EC NEEDED
DATA: g_FNAME1 TYPE STRING. "#EC NEEDED
DATA : g_repid LIKE sy-repid, "#EC NEEDED
g_exit(1) TYPE C, "#EC NEEDED
gx_variant LIKE disvariant. "#EC NEEDED
DATA : g_lines TYPE i . "#EC NEEDED
data : g_save(1) type c. "#EC NEEDED
DATA : g_splid TYPE rspoid . "#EC NEEDED
data: p_login type FILEINTERN. "#EC NEEDED
data: p_phyin type string. "#EC NEEDED

************************************************************************

  • GLOBAL CONSTANTS
    ************************************************************************

CONSTANTS c_msgar TYPE rslgarea VALUE 'F8'. "#EC NEEDED
CONSTANTS c_msgid TYPE rslgsubid VALUE 'E'. "#EC NEEDED
CONSTANTS c_urgnc TYPE char04 VALUE 'HIGH'. "#EC NEEDED
CONSTANTS C_X(1) TYPE C VALUE 'X'. "#EC NEEDED
CONSTANTS C_Y(1) TYPE C VALUE 'Y'. "#EC NEEDED
CONSTANTS C_E(1) TYPE C VALUE 'E'. "#EC NEEDED
CONSTANTS C_SAP(3) TYPE C VALUE 'SAP'. "#EC NEEDED
CONSTANTS C_MOD(3) TYPE C VALUE 'MOD'. "#EC NEEDED
CONSTANTS C_MD1(3) TYPE C VALUE 'MD1'. "#EC NEEDED
CONSTANTS C_MD2(3) TYPE C VALUE 'MD2'. "#EC NEEDED
CONSTANTS C_MD3(3) TYPE C VALUE 'MD3'. "#EC NEEDED
constants: c_000001(6) type c value '000001', "#EC NEEDED
c_e1cuv1m(7) type c value 'E1CUV1M', "#EC NEEDED
c_02(2) type c value '02', "#EC NEEDED
c_009(3) type c value '009', "#EC NEEDED
c_0001(4) type c value '0001'. "#EC NEEDED

constants: c_e1datem(7) type c value 'E1DATEM'. "#EC NEEDED
constants: c_e1cuvtm(7) type c value 'E1CUVTM'. "#EC NEEDED

************************************************************************

  • GLOBAL INTERNAL TABLES FOR ALV DISPLAY
    ************************************************************************

*Internal tables for ALV Field cat
DATA :
i_fieldcat_ov TYPE STANDARD TABLE OF slis_fieldcat_alv, "#EC NEEDED
i_fieldcat_dtl TYPE STANDARD TABLE OF slis_fieldcat_alv, "#EC NEEDED
i_fieldcat_ov1 TYPE lvc_t_fcat, "#EC NEEDED
i_events TYPE slis_t_event. "#EC NEEDED

************************************************************************

  • GLOBAL WORK AREAS FOR ALV DISPLAY
    ************************************************************************

*Work area for ALV Field layout
DATA : wa_layout TYPE slis_layout_alv. "#EC NEEDED
*Work area for Field Cat. Table
DATA : wa_fieldcat TYPE slis_fieldcat_alv. "#EC NEEDED

************************************************************************

  • GLOBAL VARIABLES FOR ALV DISPLAY
    ************************************************************************
    DATA : g_event TYPE slis_t_event. "#EC NEEDED
    DATA : g_top_of_page TYPE slis_t_listheader. "#EC NEEDED
    DATA : g_ok_code TYPE char4. "#EC NEEDED
    DATA : g_variant LIKE disvariant. "#EC NEEDED

************************************************************************

  • GLOBAL CONSTANTS FOR ALV DISPLAY
    ************************************************************************
  • BAL handling
    data: iv_log_handle type BALLOGHNDL. "#EC NEEDED
    data: is_log_header type bal_s_log. "#EC NEEDED
    data: iv_object type bal_s_log-object value 'CAPI'. "#EC NEEDED
    data: iv_subobject type bal_s_log-subobject value 'CAPI_LOG'.
    data: iv_tcode type bal_s_log-altcode value 'SE38'. "#EC NEEDED

********************************************************************
*MOD-005
********************************************************************

RANGES:
R_MESTYP FOR EDIDC-MESTYP,
R_CREDAT FOR EDIDC-CREDAT,
R_CRETIM FOR EDIDC-CRETIM,
R_SNDPRT FOR EDIDC-SNDPRT, " Partnerart (Sender)
R_SNDPRN FOR EDIDC-SNDPRN. " Partnernummer (Sender)

DATA:
L_MESSTYPE TYPE TUMLS_MESSTYPE.
********************************************************************
*MOD-005
********************************************************************
data: p_sndprn TYPE EDI_SNDPRN, "#EC NEEDED
p_sndprt TYPE EDI_SNDPRT, "#EC NEEDED
p_sndpor TYPE EDI_SNDPOR. "#EC NEEDED

data: p_rcvprn TYPE EDI_RCVPRN, "#EC NEEDED
p_rcvprt TYPE EDI_RCVPRT, "#EC NEEDED
p_rcvpor TYPE EDI_RCVPOR. "#EC NEEDED
data:
init_E1CUVTM like E1CUVTM, "#EC NEEDED
prev_E1CUVTM like E1CUVTM, "#EC NEEDED
init_E1DATEM like E1DATEM, "#EC NEEDED
prev_E1DATEM like E1DATEM, "#EC NEEDED
init_E1CUV1M like E1CUV1M, "#EC NEEDED
prev_E1CUV1M like E1CUV1M. "#EC NEEDED

  • Source structure definitions
    data:
    begin of LSMW_TAB_CONTENT,
    VTNAM(018) type C,
    CHAR1(030) type C,
    CHAR2(030) type C,
    CHAR3(030) type C,
    CHAR4(030) type C,
    CHAR5(030) type C,
    CHAR6(030) type C,
    CHAR7(030) type C,
    CHAR8(030) type C,
    CHAR9(030) type C,
    CHAR10(030) type C,
    CHAR11(030) type C,
    CHAR12(030) type C,
    CHAR13(030) type C,
    CHAR14(030) type C,
    CHAR15(030) type C,
    FLAG(001) type C,
    end of LSMW_TAB_CONTENT.

data:
begin of LSMW_VAR_TAB,
VTNAM(018) type C,
end of LSMW_VAR_TAB.

data:
begin of VAR_TAB occurs 0. "#EC NEEDED
include structure LSMW_VAR_TAB. "#EC NEEDED
data: recnr_000001 type i. "#EC NEEDED
data:
end of VAR_TAB. "#EC NEEDED

data:
begin of TAB_CONTENT occurs 0. "#EC NEEDED
include structure LSMW_TAB_CONTENT. "#EC NEEDED
data: recnr_000001 type i. "#EC NEEDED
data: recnr_000002 type i. "#EC NEEDED

data:
end of TAB_CONTENT. "#EC NEEDED

  • Counters
    data:
    g_cnt_VAR_TAB type i, "#EC NEEDED
    g_cnt_TAB_CONTENT type i. "#EC NEEDED
  • Counter ct_xxxxxxxxxx: number of transferred records
    data:
    ct_edi_dc40 type i, "#EC NEEDED
    cs_edi_dc40 type i, "#EC NEEDED
    ct_E1CUVTM type i, "#EC NEEDED
    cs_E1CUVTM type i, "#EC NEEDED
    ct_E1DATEM type i, "#EC NEEDED
    cs_E1DATEM type i, "#EC NEEDED
    ct_E1CUV1M type i, "#EC NEEDED
    cs_E1CUV1M type i. "#EC NEEDED
  • Global data definitions and data declarations

DATA: wa_cabn TYPE ty_cabn,
wa_cawn TYPE ty_cawn,
wa_file TYPE ty_file,
wa_vtnam TYPE ty_vtnam,
wa_cuvtab_fld TYPE ty_cuvtab_fld,
wa_cuvtab_valn TYPE ty_cuvtab_valn,
wa_cuvtab_valc TYPE ty_cuvtab_valc,
wa_col_pos TYPE ty_col_pos,
wa_error TYPE ty_error,
wa_dupl TYPE ty_dupl,
wa_dupl_file TYPE ty_dupl.

DATA: wa_vnt_ma TYPE ty_vnt_ma,
wa_split TYPE ty_split.

DATA: wa_charval TYPE ty_charval. "#EC NEEDED

*----------Internal table
DATA: i_cabn TYPE STANDARD TABLE OF ty_cabn, "#EC NEEDED
i_cabn_temp TYPE STANDARD TABLE OF ty_cabn, "#EC NEEDED
i_cabn_atinn TYPE STANDARD TABLE OF ty_cabn, "#EC NEEDED
i_file TYPE STANDARD TABLE OF ty_file, "#EC NEEDED
i_file_tmp TYPE STANDARD TABLE OF ty_file, "#EC NEEDED
i_vtnam TYPE STANDARD TABLE OF ty_vtnam, "#EC NEEDED
i_cuvtab TYPE STANDARD TABLE OF ty_vtnam, "#EC NEEDED
i_cuvtab_fld TYPE STANDARD TABLE OF ty_cuvtab_fld, "#EC NEEDED
i_cuvtab_valn TYPE STANDARD TABLE OF ty_cuvtab_valn, "#EC NEEDED
i_cuvtab_valc TYPE STANDARD TABLE OF ty_cuvtab_valc, "#EC NEEDED
i_col_pos TYPE STANDARD TABLE OF ty_col_pos, "#EC NEEDED
i_cawn TYPE STANDARD TABLE OF ty_cawn, "#EC NEEDED
i_cawn_n TYPE STANDARD TABLE OF ty_cawn, "#EC NEEDED
i_cawn_c TYPE STANDARD TABLE OF ty_cawn, "#EC NEEDED
i_cawn_i TYPE STANDARD TABLE OF ty_cawn, "#EC NEEDED
i_cuv_error TYPE STANDARD TABLE OF ty_vtnam, "#EC NEEDED
i_dupl TYPE STANDARD TABLE OF ty_dupl. "#EC NEEDED

DATA: i_vnt_ma TYPE STANDARD TABLE OF ty_vnt_ma, "#EC NEEDED
i_split TYPE STANDARD TABLE OF ty_split. "#EC NEEDED

DATA: i_dupl_file TYPE STANDARD TABLE OF ty_dupl. "#EC NEEDED

DATA: i_charval TYPE STANDARD TABLE OF ty_charval. "#EC NEEDED

                      • Constants
                        CONSTANTS: c_char TYPE atfor VALUE 'CHAR', "#EC NEEDED
                        c_date TYPE atfor VALUE 'DATE', "#EC NEEDED
                        c_time TYPE atfor VALUE 'TIME', "#EC NEEDED
                        c_varcond TYPE atnam VALUE 'Z_VARCOND'. "#EC NEEDED
                    • Field Symbols
                      FIELD-SYMBOLS: TYPE ty_vtnam, "#EC NEEDED
                      TYPE ty_cabn, "#EC NEEDED
                      TYPE ty_cuvtab_fld, "#EC NEEDED
                      TYPE ty_dupl. "#EC NEEDED
                  • Variables
                    DATA: g_raw(500) TYPE c, "#EC NEEDED
                    g_invalid TYPE char1, "#EC NEEDED
                    g_error TYPE char1, "#EC NEEDED
                    g_message TYPE char50, "#EC NEEDED
                    g_slnid_c TYPE slnid, "#EC NEEDED
                    g_slnid_n TYPE slnid, "#EC NEEDED
                    g_row TYPE char5. "#EC NEEDED

DATA: g_varcond TYPE varcond, "Variant condition "#EC NEEDED
g_split_var TYPE i. "#EC NEEDED

Types: begin of ty_charname,
name type atnam,
end of ty_charname.

data: wa_charname type ty_charname, "#EC NEEDED
i_charname type standard table of ty_charname. "#EC NEEDED
data: cnt_i type i, "#EC NEEDED
g_tabix type char10. "#EC NEEDED

  • IDOC Control Table
    data: begin of zedidc40 occurs 0.
    include structure edi_dc40.
    data end of zedidc40.
  • IDOC Data Table
    data: begin of zedidd40 occurs 0. "#EC NEEDED
    include structure edi_dd40.
    data end of zedidd40.

data: ze1cuvtm like e1cuvtm, "#EC NEEDED
ze1datem like e1datem, "#EC NEEDED
ze1cuv1m like e1cuv1m. "#EC NEEDED

data: wdocnum(16) type n value 0. "#EC NEEDED
data: wsegnum(6) type n value 0. "#EC NEEDED
data: witemno(10) type n value 0. "#EC NEEDED
data: witemno_new(10) type n value 0. "#EC NEEDED
data: witemno_gst(10) type n value 0. "#EC NEEDED
data: witemno_qst(10) type n value 0. "#EC NEEDED
TYPES: BEGIN OF ty_input_data1, "#EC NEEDED
line(255) type c,
flag(1) type c,
END OF ty_input_data1.

DATA: i_input_data type standard table of
ty_input_data1 initial size 0. "with header line.

DATA: i_input_data1 type standard table of
ty_input_data1 initial size 0. "with header line.

DATA: wa_input_data type ty_input_data1. "#EC NEEDED
DATA: g_cnt_input_recs type i. "#EC NEEDED
DATA: g_flg_error type c. "#EC NEEDED
DATA: l_lines type i. "#EC NEEDED
DATA: l_tabix type i. "#EC NEEDED
DATA: wa_input_data1 type ty_input_data1. "#EC NEEDED

DATA: FILE TYPE STRING.

  • Fields that are made available to the user:
    DATA:
    g_cnt_records_read TYPE i, "#EC NEEDED
    g_cnt_records_transferred TYPE i, "#EC NEEDED
    g_cnt_transactions_read TYPE i, "#EC NEEDED
    g_cnt_transactions_transferred TYPE i, "#EC NEEDED
    g_cnt_idocs_package TYPE i. "#EC NEEDED

data: v_log_handle type balloghndl.

DATA:
gt_curr_edi_dc40 LIKE edi_dc40 OCCURS 0 WITH HEADER LINE, "#EC NEEDED
gt_curr_edi_dd40 LIKE edi_dd40 OCCURS 0 WITH HEADER LINE. "#EC NEEDED

  • internal table for error messages during conversion
    DATA: g_error_tab TYPE type_errortab, "#EC NEEDED
    wa_errortab TYPE type_errorline. "#EC NEEDED

DATA: g_edidd_segnam LIKE edi_dd40-segnam, "#EC NEEDED
g_edidd_hlevel LIKE edi_dd40-hlevel. "#EC NEEDED

DATA: g_segnum(6) TYPE n.
DATA: g_objecttype(2) type C.

************************************************************************

  • INITIALIZATION
    ************************************************************************
    ************************************************************************
  • DECLARATION FOR SELECTION SCREEN
    ************************************************************************
    *---------------------------------------------------------------------
    *selection-screen skip 1.
    *---------------------------------------------------------------------
    *SELECTION-SCREEN BEGIN OF BLOCK bl5 WITH FRAME TITLE text-035.
    **
    *parameters:
    • p_trfc TYPE /SAPDMC/LS_TRFCPORT obligatory,
    • p_ptype TYPE EDIPPARTYP obligatory,
    • p_sndpr TYPE EDIPPARNUM obligatory,
  • p_rcvpr TYPE EDIPPARNUM obligatory.
    • p_mestyp TYPE EDI4MESTYP obligatory,
    • p_idoc TYPE EDI4IDOCTP obligatory.
      *SELECTION-SCREEN END OF BLOCK bl5.
      *

SELECTION-SCREEN BEGIN OF BLOCK bl3 WITH FRAME TITLE text-032.

  • Radio Buttons :
    parameters:
    rb_apsrv RADIOBUTTON GROUP RB1 DEFAULT 'X' USER-COMMAND UCOM,
    rb_prsrv RADIOBUTTON GROUP RB1.

SELECTION-SCREEN END OF BLOCK bl3.

*For all the input field entries
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
*Parameter for Input File Name:
PARAMETERS: p_inpt TYPE RLGRAP-FILENAME MODIF ID MOD .
PARAMETERS: p_inpt1 TYPE RLGRAP-FILENAME MODIF ID MOD .

SELECTION-SCREEN END OF BLOCK bl1.

SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-030.
parameters : p_fpath type filename-FILEINTERN MODIF ID MD1 .
"Logical Filepath
PARAMETERS : P_fname TYPE LOCALFILE MODIF ID MD1 .
" Physical File path
parameters : p_fpath1 type filename-FILEINTERN MODIF ID MD1 .
"Logical Filepath
PARAMETERS : P_fname1 TYPE LOCALFILE MODIF ID MD1 .
" Physical File path

SELECTION-SCREEN END OF BLOCK bl2.

SELECTION-SCREEN BEGIN OF BLOCK bl4 WITH FRAME TITLE text-033.
parameters:
p_upload as checkbox default C_X MODIF ID MD2,

  • Input file from NT server
    p_inbd as checkbox default C_X MODIF ID MD2,
  • Create idocs
    p_proc as checkbox default C_X MODIF ID MD2.
    SELECTION-SCREEN END OF BLOCK bl4.
    • IDoc creation
      selection-screen begin of block idocpars
      with frame title text-006.
      parameters:
      p_trfcpt as checkbox default C_X MODIF ID MD3,
      p_packge(5) type n default 1 MODIF ID MD3.
      selection-screen end of block idocpars.

************************************************************************

  • INITIALIZATION
    ************************************************************************

INITIALIZATION.

*Initialization of all the Global Variables
PERFORM sub_refresh_variables.

CONCATENATE C_SAP sy-sysid INTO p_rcvpor.
CONCATENATE C_SAP sy-sysid INTO p_rcvprn.

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET' "#EC *
IMPORTING
own_logical_system = p_rcvprn
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.

************************************************************************

  • Check selection-screen entries *
    ************************************************************************

AT SELECTION-SCREEN.

PERFORM sub_get_physical_file USING p_fpath p_fname.

PERFORM sub_get_physical_file1 USING p_fpath1 p_fname1.

************************************************************************

  • AT SELECTION SCREEN
    ************************************************************************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
    PERFORM sub_get_file. " CHANGING p_fname. "#EC *

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname1.
PERFORM sub_get_file1. " CHANGING p_fname1. "#EC *

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INPT.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = C_X
CHANGING
FILE_NAME = P_INPT
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.

IF SY-SUBRC <> 0.
MESSAGE e241.
ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INPT1.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = C_X
CHANGING
FILE_NAME = P_INPT1
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.

IF SY-SUBRC <> 0.
MESSAGE e241.
ENDIF.

&---------------------------------------------------------------------

  • At Selection Screen Output
    &---------------------------------------------------------------------

AT SELECTION-SCREEN OUTPUT.

IF rb_apsrv = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = c_mod.
SCREEN-INPUT = 0.
ENDIF.
IF SCREEN-GROUP1 = c_md2.
SCREEN-INPUT = 0.
ENDIF.
IF SCREEN-GROUP1 = c_md3.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
endif.

IF rb_prsrv = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = c_md1.
SCREEN-INPUT = 0.
ENDIF.
IF SCREEN-GROUP1 = c_md2.
SCREEN-INPUT = 0.
ENDIF.
IF SCREEN-GROUP1 = c_md3.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
endif.

************************************************************************

  • START-OF-SELECTION
    ************************************************************************

START-OF-SELECTION.

*Subroutines for start of selection event
PERFORM sub_start_selection.

PERFORM sub_upload_data.

  • Get characteristic details
    PERFORM sub_get_cabn.
  • Get value for characteristics
    PERFORM sub_get_cawn.

**************************************************************
*MOD-008
**************************************************************
perform sub_convert_transaction.

IF g_error <> c_x.
PERFORM SUB_CREATE_IDOCS.
PERFORM SUB_START_IDOC_PROCESS.
ENDIF.

END-OF-SELECTION.
************************************************************************

  • END OF SELECTION
    ************************************************************************
  • Final message
    perform sub_final_message_idoc.
  • Display errorneous variant tables.
    perform sub_display_variant.
  • Display lines with incorrect data
    perform sub_display_errorlines.

*Subroutines for end of selection event
PERFORM sub_end_selection.

perform sub_clear_source_tables.

&---------------------------------------------------------------------
*& Include ZFACTGLB_GTDMI_VARTAB_FORMS
&---------------------------------------------------------------------

&---------------------------------------------------------------------
*& Include /FACTGLB/GTDMI_VARTAB_FORMS
&---------------------------------------------------------------------

----------------------------------------------------------------------

  • PROGRAM DESCRIPTION: Variant Table and Content Upload Interface.
    *
  • DEVELOPER: Aveek Ghose
  • CREATION DATE: 2008-04-18
  • RDD NUMBER: DCDD027
  • TRANSPORT NUMBER(S): RD2K902769
    *
      • REVISION HISTORY --------------------------------------------------*
        *
  • DEVELOPER:
  • DATE APPLIED: YYYY-MM-DD
  • SCR NUMBER:
  • RDD NUMBER:
  • TRANSPORT NUMBER(S):
  • DESCRIPTION:
    *
    ----------------------------------------------------------------------

&---------------------------------------------------------------------
*& Form sub_refresh_variables
&---------------------------------------------------------------------

  • This Subroutien Rfreshes all the Global Variables, Internal Tables
  • and Work Areas usd in this program
    ----------------------------------------------------------------------

FORM sub_refresh_variables .
**********************************

    • REFRESH GLOBAL INTERNAL TABLES
      **********************************

****************************

  • REFRESH GLOBAL WORK AREAS
    ****************************

*Work Area for the structure I_MESSTAB
CLEAR: wa_vartab,
wa_vartabdate,
wa_vardetails,
wa_tabinput,
wa_dsninput,
wa_dsninput,
wa_newinput,
wa_gnewinput,
wa_ginput_data ,
wa_final,
wa_content,
wa_contenthd ,
wa_contentheader,
wa_contenttab,
wa_content1,
wa_contenthd1,
wa_contentheader1,
wa_contenttab1,
wa_E1CUVTM ,
wa_E1CUV1M ,
wa_E1DATEM .

*************************************************

  • REFRESH INTERNAL TABLES AND WORK AREAS FOR BDC
    *************************************************

*Internal Table to store the data to display the error message
REFRESH i_errormsg[] .

*Internal Table to store the data to display the error message
REFRESH i_error[].

**Work area to store the data to display the error message
CLEAR wa_errormsg.

*Internal table which will store data for the error log
REFRESH i_error_log[] .

***************************

  • REFRESH GLOBAL VARIABLES
    ***************************
    CLEAR: g_ctr_input_recs,
    g_ctr_output_recs,
    g_msg,
    g_struct_file,
    g_login,
    g_phyin ,
    g_FNAME1,
    g_repid,
    g_exit,
    gx_variant,
    g_lines ,
    g_save,
    g_splid ,
    p_login ,
    p_phyin.

*************************************************

  • REFRESH GLOBAL INTERNAL TABLES FOR ALV DISPLAY
    *************************************************
    *Refresh Internal tables for ALV Field cat
    REFRESH i_fieldcat_ov[].
    REFRESH i_fieldcat_dtl[].
    REFRESH i_fieldcat_ov1[].
    REFRESH i_events[].

********************************************

  • REFRESH GLOBAL WORK AREAS FOR ALV DISPLAY
    ********************************************
    *Work area for ALV Field layout
    CLEAR wa_layout.
    *Work area for Field Cat. Table
    CLEAR wa_fieldcat.

CLEAR:
g_cnt_records_read,
g_cnt_records_transferred,
g_cnt_transactions_read,
g_cnt_transactions_transferred.

ENDFORM. " sub_refresh_variables

*
*&---------------------------------------------------------------------
*& Form sub_populate_syslog
*&---------------------------------------------------------------------

  • Populate the error message
    ----------------------------------------------------------------------
    FORM sub_populate_syslog. " TABLES i_error STRUCTURE solisti1. "#EC *

constants: c_lp01(4) type c value 'LP01'.
data: c_99 type i value 99.
g_repid = sy-repid.
g_lprnt = c_lp01.

DESCRIBE TABLE i_errortab LINES g_lines.

IF g_lines GT 0.

  • To display the Text data in Spool
    CALL FUNCTION 'RSPO_SX_OUTPUT_TEXTDATA'
    EXPORTING
    dest = g_lprnt
    rows = g_lines
    startrow = 1
    pages = c_99
    rqtitle = text-029
    immediately = space
    IMPORTING
    rqid = g_splid
    TABLES
    text_data = i_errortab
    EXCEPTIONS
    name_missing = 1
    name_twice = 2
    not_found = 3
    illegal_layout = 4
    internal_error = 5
    size_mismatch = 6
    OTHERS = 7. "#EC NOTEXT

IF sy-subrc EQ 0.
g_repid = sy-repid.

  • To write the spool number of the error log to System log
    CALL FUNCTION 'RSLG_WRITE_SYSLOG_ENTRY'
    EXPORTING
    data_word1 = c_urgnc " Urgency
    data_word2 = g_splid " Spool Number
    data_word3 = g_repid " Program Name
    sl_message_area = c_msgar " Message Area
    sl_message_subid = c_msgid
    EXCEPTIONS
    data_missing = 1 " Third character of msg area
    data_words_problem = 2
    other_problem = 3
    pre_params_problem = 4
    OTHERS = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

ENDIF.
ENDIF.

ENDFORM. " sub_populate_syslog

&---------------------------------------------------------------------
*& Form SUB_UPLOAD_DATA
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_UPLOAD_DATA .

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "#EC *
EXPORTING
percentage = 0
text = text-005.

if rb_apsrv = 'X'.

  • Upload from application server
    perform sub_upload_from_appserver.
    else.
  • Upload from presentation server
    perform sub_upload_from_preserver.
    endif.

ENDFORM. " SUB_UPLOAD_DATA
&---------------------------------------------------------------------
*& Form sub_get_physical_file
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_P_FPATH text
  • -->P_P_LPATH text
    ----------------------------------------------------------------------
    FORM sub_get_physical_file USING p_lfile type FILEINTERN "#EC *
    p_pfile type LOCALFILE. "#EC *

CHECK NOT p_lfile IS INITIAL.

CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
client = sy-mandt
logical_filename = p_lfile
operating_system = sy-opsys
IMPORTING
file_name = p_pfile
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
p_pfile = '' .
MESSAGE e237 WITH p_lfile.
ENDIF.

ENDFORM. " sub_get_physical_file
**&---------------------------------------------------------------------
*
*& Form sub_end_selection
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM sub_end_selection .
    *Population of Error Log

IF g_error_tab[] IS NOT INITIAL.
PERFORM sub_create_erortab. "#EC *
PERFORM sub_populate_syslog. "tables i_errortab. "#EC *
ENDIF.

  • Population of Application Log*
    IF NOT G_ERROR_TAB[] IS INITIAL.
    PERFORM sub_app_log_init CHANGING v_log_handle. "#EC *
    PERFORM sub_app_log_add USING v_log_handle. "#EC *
    PERFORM sub_data_save USING v_log_handle. "#EC *
    PERFORM sub_log_show USING v_log_handle. "#EC *
    ENDIF.

ENDFORM. " sub_end_selection
&---------------------------------------------------------------------
*& Form sub_start_selection
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM sub_start_selection .

SET PF-STATUS '/FACTGLB/DMIVART'. "EXCLUDING rt_extab.

*Initialization of all the Global Variables
PERFORM sub_refresh_variables.

CONCATENATE C_SAP sy-sysid INTO p_rcvpor.
CONCATENATE C_SAP sy-sysid INTO p_rcvprn.

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET' "#EC *
IMPORTING
own_logical_system = p_rcvprn
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.

IF rb_apsrv = C_X.
IF p_fpath IS INITIAL.
message i196.
LEAVE LIST-PROCESSING.
ENDIF.

IF p_fname IS INITIAL.
message i197.
LEAVE LIST-PROCESSING.
ENDIF.
IF p_fpath1 IS INITIAL.
message i196.
LEAVE LIST-PROCESSING.
ENDIF.

IF p_fname1 IS INITIAL.
message i197.
LEAVE LIST-PROCESSING.
ENDIF.

ENDIF.

IF rb_prsrv = C_X.
IF p_inpt IS INITIAL.
message i196.
LEAVE LIST-PROCESSING.
ENDIF.

IF p_inpt1 IS INITIAL.
message i197.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.

g_objecttype = '04'.

ENDFORM. " sub_start_selection
&---------------------------------------------------------------------
*& Form SUB_GET_PHYSICAL_FILE1
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_P_FPATH text
  • -->P_P_FNAME text
    ----------------------------------------------------------------------
    FORM sub_get_physical_file1 USING p_lfile1 type FILEINTERN"#EC *
    p_pfile1 type LOCALFILE."#EC *

CHECK NOT p_lfile1 IS INITIAL.

CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
client = sy-mandt
logical_filename = p_lfile1
operating_system = sy-opsys
IMPORTING
file_name = p_pfile1
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
p_pfile1 = '' .
MESSAGE e237 WITH p_lfile1.
ENDIF.

ENDFORM. " sub_get_physical_file1
&---------------------------------------------------------------------
*& Form SUB_GET_PHYSICAL_FILE1
&---------------------------------------------------------------------

  • User-defined routines]

****************************************************************
**MOD-006
****************************************************************

    • Eigene Routine
      *form ur_CONVERSION_EXIT "#EC CALLED
  • using p_in1 "#EC *
  • p_in2 "#EC *
  • changing p_out. "#EC *
    *
  • DATA: v_msgtext(120) TYPE c.
    *
  • CONSTANTS: c_msgtyp(001) TYPE c VALUE 'I', "#EC NEEDED
  • c_msgid(020) TYPE c VALUE 'ZDEV'. "#EC NEEDED
    *
  • CALL FUNCTION p_in1 "#EC *
  • EXPORTING
  • input = p_in2 "#EC *
  • IMPORTING
  • output = p_out. "#EC *
    *
  • IF sy-subrc NE 0.
  • CLEAR v_msgtext.
    *************************************************
    **MOD-008
    *************************************************
    • MESSAGE ID c_msgid
    • TYPE c_msgtyp
    • NUMBER '096'
    • WITH sy-subrc
    • p_in2
    • INTO v_msgtext.
      **************************************************
      ***MOD-008
      **************************************************
    • WRITE / v_msgtext.
    • CLEAR v_msgtext.
  • ENDIF.
    *endform. "ur_CONVERSION_EXIT "#EC CALLED

&---------------------------------------------------------------------
*& Form get_internal_char
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_CHARAC text
  • -->P_CABN text
  • -->P_VTNAM text
    ----------------------------------------------------------------------
    FORM get_internal_char USING p_charac TYPE atnam
    CHANGING p_cabn TYPE ty_cabn
    p_vtnam TYPE ty_vtnam.

sort i_cabn by atinn atnam.
READ TABLE i_cabn INTO p_cabn
WITH KEY atnam = p_charac. " BINARY SEARCH.

IF sy-subrc <> 0.
p_vtnam-error = C_X.
CONCATENATE p_charac text-012 "#EC NOTEXT
INTO p_vtnam-reas SEPARATED BY space.

  • p_vtnam-reas = 'Characteristic name is not valid'.
    g_error = c_x.
    CLEAR wa_vtnam.
    wa_vtnam = p_vtnam.
    APPEND wa_vtnam TO i_cuv_error.

wa_errortab-msgty = C_E.
wa_errortab-id = '/factglb/gta_custdev'.
wa_errortab-msgno = 001.
wa_errortab-par1 = wa_vtnam-reas.
INSERT wa_errortab INTO TABLE g_error_tab.
ENDIF.

ENDFORM. "get_internal_char

&---------------------------------------------------------------------
*& Form find_char_exist
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> text
  • -->WA_CABN text
    ----------------------------------------------------------------------
    FORM find_char_exist USING p_file TYPE ty_file "#EC NEEDED
    p_vtnam TYPE ty_vtnam "#EC NEEDED
    p_cabn TYPE ty_cabn. "#EC NEEDED

DATA: l_quot TYPE char2, "#EC NEEDED
l_pos TYPE char3. "#EC NEEDED

IF p_vtnam-error IS INITIAL.
sort i_cuvtab_fld by vtint atinn.
READ TABLE i_cuvtab_fld ASSIGNING
WITH KEY vtint = p_vtnam-vtint
atinn = p_cabn-atinn
BINARY SEARCH.
IF sy-subrc = 0.
-exist = c_x.
READ TABLE i_charname INTO wa_charname
WITH KEY name = p_cabn-atnam.
IF sy-subrc = 0.
g_tabix = sy-tabix.
SHIFT g_tabix LEFT DELETING LEADING space.
l_quot = g_tabix+0(2).
ENDIF.
wa_col_pos-vtint = p_vtnam-vtint.
wa_col_pos-vtnam = p_vtnam-vtnam.
wa_col_pos-atnam = p_cabn-atnam.
wa_col_pos-atinn = p_cabn-atinn.
wa_col_pos-field = l_quot.
wa_col_pos-vtpos = -vtpos.
APPEND wa_col_pos TO i_col_pos.
CLEAR wa_col_pos.
ENDIF.
ENDIF.
ENDFORM. "find_char_exist

&---------------------------------------------------------------------
*& Form transfer_e1cuv1m
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_E1CUV1M text
    ----------------------------------------------------------------------
    FORM transfer_e1cuv1m. " USING p_e1cuv1m TYPE e1cuv1m. "#EC *

constants: c_000001(6) type c value '000001',
c_e1cuv1m(7) type c value 'E1CUV1M',
c_02(2) type c value '02',
c_009(3) type c value '009',
c_0001(4) type c value '0001'.

CLEAR e1cuv1m.
e1cuv1m = wa_e1cuv1m. "#EC NEEDED
zedidd40-docnum = wdocnum.
zedidd40-segnum = c_000001.
zedidd40-segnam = c_E1CUV1M.
zedidd40-hlevel = c_02.
E1CUV1M-MSGFN = c_009.
E1CUV1M-VTLINENO = c_0001.
zedidd40-sdata = e1cuv1m.

  • append zedidd40. " e1cuvtm
    witemno = 0. "#EC NEEDED
    witemno_gst = 0. "#EC NEEDED .
    witemno_qst = 0. "#EC NEEDED
    witemno_new = 0. "#EC NEEDED
    wsegnum = 1. "#EC NEEDED
    clear: wa_e1cuv1m. "#EC NEEDED
    clear: ze1cuv1m. "#EC NEEDED
    ****************************************************
    *MOD-009
    ****************************************************
  • IF p_trfcpt = C_X.
  • gt_curr_edi_dd40 = zedidd40.
  • APPEND gt_curr_edi_dd40.
  • ENDIF.
    *
    ****************************************************
    *MOD-009
    ****************************************************
    READ TABLE zedidc40 index 1.

CASE g_objecttype.
WHEN '03' OR '04'.
IF zedidc40-tabnam = zedidc40.
IF p_trfcpt = 'X'.
gt_curr_edi_dc40 = 'EDI_DC40'.
APPEND gt_curr_edi_dc40.
ENDIF.
ELSE.

  • CLEAR edi_dd40.
  • edi_dd40-segnam = zedidd40-segnam.
    • edi_dd40-mandt = edi_dc40-mandt.
  • edi_dd40-docnum = zedidd40-docnum.
  • ADD 1 TO g_segnum.
  • edi_dd40-segnum = g_segnum.
  • edi_dd40-hlevel = g_edidd_hlevel.
  • edi_dd40-sdata = zedidd40.
    IF p_trfcpt = c_x.
    gt_curr_edi_dd40 = zedidd40.
    APPEND gt_curr_edi_dd40.
    ENDIF.
    ENDIF.
    ENDCASE.

****************************************************
*MOD-009
****************************************************
ENDFORM. "transfer_e1cuv1m

&---------------------------------------------------------------------
*& Form transfer_e1cuvtm
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_E1CUVTM text
    ----------------------------------------------------------------------
    FORM transfer_e1cuvtm USING p_e1cuvtm TYPE e1cuvtm. "#EC CALLED

CLEAR e1cuvtm.
e1cuvtm = p_e1cuvtm.
*MOD-009

  • perform transfer_record_idoc.
    *MOD-009
    CLEAR edi_dd40.
    edi_dd40-segnam = g_edidd_segnam.
    edi_dd40-mandt = edi_dc40-mandt.
    edi_dd40-docnum = edi_dc40-docnum.
    ADD 1 TO g_segnum.
    edi_dd40-segnum = g_segnum.
    edi_dd40-hlevel = g_edidd_hlevel.
    edi_dd40-sdata = e1cuvtm.
    IF p_trfcpt = C_X.
    gt_curr_edi_dd40 = edi_dd40.
    APPEND gt_curr_edi_dd40.
    ENDIF.

ENDFORM. "transfer_e1cuvtm "#EC CALLED
&---------------------------------------------------------------------
*& Form transfer_e1datem
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
    FORM transfer_e1datem. "#EC CALLED

CLEAR e1datem.
e1datem-msgfn = '009'.
e1datem-key_date = sy-datum.
perform transfer_record_idoc.
CLEAR edi_dd40.
edi_dd40-segnam = g_edidd_segnam.
edi_dd40-mandt = edi_dc40-mandt.
edi_dd40-docnum = edi_dc40-docnum.
ADD 1 TO g_segnum.
edi_dd40-segnum = g_segnum.
edi_dd40-hlevel = g_edidd_hlevel.
edi_dd40-sdata = e1datem.
IF p_trfcpt = C_X.
gt_curr_edi_dd40 = edi_dd40.
APPEND gt_curr_edi_dd40.
ENDIF.

ENDFORM. "transfer_e1cuvtm "#EC CALLED

&---------------------------------------------------------------------
*& Form errror_line
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_VTNAM Variant table
  • -->P_FIELDNAME Fieldname
  • -->P_ATNAM Characteristic name
  • -->P_VAL Value
  • -->P_ROW Rowid
    ----------------------------------------------------------------------
    FORM errror_line USING p_vtnam TYPE vtnam
    p_fieldname TYPE fieldname
    p_atnam TYPE atnam
    p_val TYPE atwrt
    p_row TYPE char5.
    CLEAR wa_error.
    wa_error-vtnam = p_vtnam.
    wa_error-fname = p_fieldname.
    wa_error-atnam = p_atnam.
    wa_error-atwrt = p_val.
    wa_error-row = p_row.
    APPEND wa_error TO i_error.
    ENDFORM. "errror_line

&---------------------------------------------------------------------
*& Form delete_duplicates
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
    FORM sub_delete_duplicates. "#EC CALLED

SORT i_file.
DELETE ADJACENT DUPLICATES FROM i_file.
ENDFORM. "sub_delete_duplicates "#EC CALLED

&---------------------------------------------------------------------
*& Form pop_dupl
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • -->P_VTNAM text
  • -->P_SLNID text
  • -->P_ATNAM text
  • -->P_VAL text
    ----------------------------------------------------------------------
    FORM pop_dupl USING p_vtnam TYPE vtnam
    p_slnid TYPE slnid
    p_atnam TYPE atnam
    p_val TYPE any.

DATA: l_field TYPE fieldname.
FIELD-SYMBOLS: TYPE ANY.

  • Do not populate value for characteristic Z_VARCOND as it will not be
  • part of duplicate check
    IF p_atnam NE c_varcond.
  • assign p_val to .
    CLEAR wa_col_pos.
    *****************************************************
    *MOD-008
    *****************************************************
    SORT i_col_pos BY vtint
    vtnam
    atinn
    atnam.
    *****************************************************
    *MOD-008
    *****************************************************
    READ TABLE i_col_pos INTO wa_col_pos WITH KEY vtnam = p_vtnam
    atnam = p_atnam.
  • No need to check sy-subrc here
    CLEAR l_field.

READ TABLE i_dupl ASSIGNING WITH KEY vtnam = p_vtnam
slnid = p_slnid.
IF sy-subrc = 0.

CONCATENATE '-CHAR' wa_col_pos-field INTO l_field.
ASSIGN (l_field) TO .
= p_val.
ELSE.
CLEAR wa_dupl.
wa_dupl-vtnam = p_vtnam.
wa_dupl-slnid = p_slnid.
CONCATENATE 'WA_DUPL-CHAR' wa_col_pos-field INTO l_field.
ASSIGN (l_field) TO .
= p_val.
APPEND wa_dupl TO i_dupl.

ENDIF.
ENDIF.
ENDFORM. "pop_dupl

&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form TRANSFER_RECORD_IDOC
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM TRANSFER_RECORD_IDOC . "#EC CALLED

READ TABLE zedidc40 index 1.

CASE g_objecttype.
WHEN '03' OR '04'.
IF zedidc40-tabnam = 'EDI_DC40'.
IF p_trfcpt = 'X'.
gt_curr_edi_dc40 = zedidc40.
APPEND gt_curr_edi_dc40.
ENDIF.
ELSE.
CLEAR edi_dd40.
edi_dd40-segnam = g_edidd_segnam.
edi_dd40-mandt = edi_dc40-mandt.
edi_dd40-docnum = edi_dc40-docnum.
ADD 1 TO g_segnum.
edi_dd40-segnum = g_segnum.
edi_dd40-hlevel = g_edidd_hlevel.
edi_dd40-sdata = zedidd40.
IF p_trfcpt = c_x.
gt_curr_edi_dd40 = zedidd40.
APPEND gt_curr_edi_dd40.
ENDIF.
ENDIF.
ENDCASE.

ENDFORM. " TRANSFER_RECORD_IDOC "#EC CALLED

*********************************************************************
*MOD-008
*********************************************************************

&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form FILL_EDIDD_SEGMENTS
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM FILL_EDIDD_SEGMENTS USING p_e1cuv1m TYPE e1cuv1m. "#EC CALLED

LOOP AT I_CONTENTTAB1 INTO WA_CONTENTTAB1.
IF SY-TABIX = 1.
wa_contenttab2 = wa_contenttab1.
append wa_contenttab2 to i_contenttab2.
clear: wa_contenttab2.
ENDIF.
ENDLOOP.

LOOP AT I_CONTENTTAB1 INTO WA_CONTENTTAB1.
L_TABIX = SY-TABIX.
IF L_TABIX > 1.
READ TABLE I_CONTENTTAB2 INTO WA_CONTENTTAB2
WITH KEY VTNAM = WA_CONTENTTAB1-VTNAM BINARY SEARCH.

IF SY-SUBRC = 0.

        • E1CUV1M-VTCHARACT
          *if not WA_CONTENTTAB1-VTCHARACT is initial.
          if not WA_CONTENTTAB1-CHAR1 is initial.
  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
          • E1CUV1M-VTLINENO
            E1CUV1M-MSGFN = c_009.
            E1CUV1M-VTLINENO = c_0001.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR1.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR1.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR2 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR2.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR2.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED
      endif.

if not WA_CONTENTTAB1-CHAR3 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR3.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR3.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED
      endif.

if not WA_CONTENTTAB1-CHAR4 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR4.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR4.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR5 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR5.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR5.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED
      endif.

if not WA_CONTENTTAB1-CHAR6 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR6.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR6.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

If not WA_CONTENTTAB1-CHAR7 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR7.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR7.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR8 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR8.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR8.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR9 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR9.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR9.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR10 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.

E1CUV1M-MSGFN = '009'.
E1CUV1M-VTLINENO = '0001'.

    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR10.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR10.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR11 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR11.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR11.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR12 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR12.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR12.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR13 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR13.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR13.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

if not WA_CONTENTTAB1-CHAR14 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR14.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR14.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED
      endif.

if not WA_CONTENTTAB1-CHAR15 is initial.

  • E1CUV1M-VTCHARACT = TAB_CONTENT-ATNAM.
    E1CUV1M-MSGFN = '009'.
    E1CUV1M-VTLINENO = '0001'.
    • — E1CUV1M-MSGFN
      E1CUV1M-VTCHARACT = WA_CONTENTTAB2-CHAR15.
      E1CUV1M-ATWRT = WA_CONTENTTAB1-CHAR15.
      zedidd40-docnum = wdocnum.
      zedidd40-segnum = c_000001.
      zedidd40-segnam = p_E1CUV1M.
      zedidd40-hlevel = c_02.
      zedidd40-sdata = e1cuv1m.
      append zedidd40. " e1cuvtm
      witemno = 0. "#EC NEEDED
      witemno_gst = 0. "#EC NEEDED .
      witemno_qst = 0. "#EC NEEDED
      witemno_new = 0. "#EC NEEDED
      wsegnum = 1. "#EC NEEDED
      clear: wa_e1cuv1m. "#EC NEEDED
      clear: ze1cuv1m. "#EC NEEDED

endif.

CLEAR: wa_contenttab2.
ENDIF.
CLEAR: L_TABIX.
ENDIF.
CLEAR: wa_contenttab1.
ENDLOOP.

perform transfer_record_idoc.

ENDFORM. " FILL_EDIDD_SEGMENTS
&---------------------------------------------------------------------
*& Form SUB_GET_CABN
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CABN .

DATA: I_CABN_CHAR TYPE STANDARD TABLE OF ty_content INITIAL SIZE 0.
"#EC NEEDED
DATA: WA_CABN_CHAR TYPE TY_CONTENT.

READ TABLE I_CONTENTTAB1 INTO WA_CONTENTTAB1 INDEX 1.
MOVE-CORRESPONDING WA_CONTENTTAB1 TO WA_CABN_CHAR.
APPEND WA_CABN_CHAR TO I_CABN_CHAR.
CLEAR: WA_CABN_CHAR.

*****************************************************
****MOD-008
*****************************************************

  • SELECT atinn atnam atfor
  • atson atprt atprr
  • atprf anzdz FROM cabn
  • INTO TABLE i_cabn.
    ******************************************************
    *****MOD-008
    ******************************************************

SELECT atinn
atnam
atfor
atson
atprt
atprr
atprf
anzdz
FROM cabn
INTO TABLE i_cabn
FOR ALL ENTRIES IN I_CABN_CHAR
WHERE ( ATNAM = i_cabn_char-char1 or
ATNAM = i_cabn_char-char2 or
ATNAM = i_cabn_char-char3 or
ATNAM = i_cabn_char-char4 or
ATNAM = i_cabn_char-char5 or
ATNAM = i_cabn_char-char6 or
ATNAM = i_cabn_char-char7 or
ATNAM = i_cabn_char-char8 or
ATNAM = i_cabn_char-char9 or
ATNAM = i_cabn_char-char10 or
ATNAM = i_cabn_char-char11 or
ATNAM = i_cabn_char-char12 or
ATNAM = i_cabn_char-char13 or
ATNAM = i_cabn_char-char14 or
ATNAM = i_cabn_char-char15 ).

IF sy-subrc = 0.
SORT i_cabn BY atinn atnam.
delete i_cabn where atnam is initial.
i_cabn_temp[] = i_cabn[].
i_cabn_atinn[] = i_cabn[].

  • Sort IT by internal characteristic number
    SORT i_cabn_atinn BY atinn atnam.
    DELETE ADJACENT DUPLICATES FROM i_cabn_atinn COMPARING atinn atnam.

DELETE i_cabn_temp
WHERE atson IS NOT INITIAL
AND atprt IS NOT INITIAL
AND atprr IS NOT INITIAL
AND atprf IS NOT INITIAL.

ENDIF.

ENDFORM. " SUB_GET_CABN
&---------------------------------------------------------------------
*& Form SUB_GET_CAWN
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CAWN .

IF NOT i_cabn_temp[] is initial.

SELECT atinn
atzhl
atwrt
atflv
lkenz
FROM cawn
INTO TABLE i_cawn
FOR ALL ENTRIES IN i_cabn_temp
WHERE atinn = i_cabn_temp-atinn.

IF sy-subrc = 0.
i_cawn_c[] = i_cawn[].
DELETE i_cawn_c WHERE atwrt IS INITIAL.
SORT i_cawn_c BY atinn atwrt.

i_cawn_n = i_cawn.
DELETE i_cawn_n WHERE atflv IS INITIAL.
SORT i_cawn_n BY atinn atflv.

i_cawn_i = i_cawn.
SORT i_cawn_i BY atinn.
DELETE ADJACENT DUPLICATES FROM i_cawn_i COMPARING atinn.
ENDIF.
ENDIF.

ENDFORM. " SUB_GET_CAWN
&---------------------------------------------------------------------
*& Form SUB_CONVERT_TRANSACTION
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CONVERT_TRANSACTION .

DATA: L_TABLE TYPE APITABL.
DATA: L_CHANGE_NUMBER TYPE AENNR.
DATA: L_DLOCK LIKE CUVTAB_ST-DLOCK_CONT,
ITAB_VT_BASIC_DATA LIKE VTBASDAT,
L_DATE LIKE CLBASD-VAL_FROM,
L_LINE_NO TYPE I.
DATA: wa_char_tab_entries type VTBASDAT.
DATA: ITAB_VAR_TAB_ENTRIES LIKE VTENTRIES OCCURS 30 WITH HEADER
LINE.

PERFORM sub_clear_tables.

********************************************************
*MOD-009
********************************************************

loop at i_contentheader1 into wa_contentheader1.

CALL FUNCTION 'CARD_TABLE_READ_STRUCTURE'
EXPORTING
VAR_TAB = WA_CONTENTHEADER1-VTNAM
CHANGE_NO = L_CHANGE_NUMBER
DATE = L_DATE
IMPORTING
BASIC_DATA = ITAB_VT_BASIC_DATA
EXCEPTIONS
ERROR = 1
OTHERS = 2.

CHECK SY-SUBRC IS INITIAL.

CALL FUNCTION 'CARD_TABLE_READ_ENTRIES'
EXPORTING
VAR_TABLE = WA_CONTENTHEADER1-VTNAM
CHANGE_NO = L_CHANGE_NUMBER
DATE = L_DATE
TABLES
VAR_TAB_ENTRIES = ITAB_VAR_TAB_ENTRIES
EXCEPTIONS
ERROR = 1
OTHERS = 2.

ENDLOOP.

loop at i_contenttab1 into wa_contenttab1.
if sy-tabix = 1.
continue.
endif.
loop at itab_var_tab_entries into wa_char_tab_entries where
( VTVALUE = wa_contenttab1-char1
or
VTVALUE = wa_contenttab1-char2
or
VTVALUE = wa_contenttab1-char3
or
VTVALUE = wa_contenttab1-char4
or
VTVALUE = wa_contenttab1-char5
or
VTVALUE = wa_contenttab1-char6
or
VTVALUE = wa_contenttab1-char7
or
VTVALUE = wa_contenttab1-char8
or
VTVALUE = wa_contenttab1-char9
or
VTVALUE = wa_contenttab1-char10
or
VTVALUE = wa_contenttab1-char11
or
VTVALUE = wa_contenttab1-char12
or
VTVALUE = wa_contenttab1-char13
or
VTVALUE = wa_contenttab1-char14
or
VTVALUE = wa_contenttab1-char15
).

if sy-subrc = 0.
wa_contenttab1-flag = C_Y.
modify i_contenttab1 from wa_contenttab1 transporting flag.
endif.
endloop.
endloop.

Delete i_contenttab1 where flag = C_Y.

I_CONTENTTAB3[] = I_CONTENTTAB1[].

SORT I_CONTENTTAB3 BY VTNAM.

DELETE I_CONTENTTAB3 WHERE VTNAM IS INITIAL.

  • DELETE ADJACENT DUPLICATES FROM I_CONTENTTAB1.
    CLEAR: L_LINES.
    DESCRIBE TABLE I_CONTENTTAB3 LINES L_LINES.
    IF L_LINES = 1.
    g_error = 'X'.
    CLEAR wa_vtnam.
    MESSAGE I144.
    LEAVE LIST-PROCESSING.
    ENDIF.

**********************************************************************
*MOD-009
**********************************************************************
IF G_ERROR <> C_X.
**********************************************************************
*MOD-009
**********************************************************************

loop at i_contentheader1 into wa_contentheader1.
perform sub_convert_0001. " E1CUVTM
perform sub_convert_0002. " E1DATEM'
loop at i_contenttab1 into wa_contenttab1.

  • where VTNAM = wa_contentheader1-VTNAM.
    perform sub_convert_0003. " E1CUV1M
    clear: wa_contenttab1.
    ENDLOOP.
    clear: wa_contentheader1.
    ENDLOOP.
  • Delete Duplicates:

PERFORM sub_delete_duplicates.

  • Get internal variant table number, store in internal table I_CUVTAB
    PERFORM sub_get_cuvtab. " using wa_contentheader1.
  • Get unique number for variant table from table /FACTGLB/DVNT_MA
    PERFORM sub_get_vnt_ma. " using wa_contentheader1.
  • Get internal table fields and their order
    PERFORM sub_get_cuvtab_fld. " using wa_contentheader1.

clear: wa_contentheader1.

  • Find out if check is required for characteristic, if no value
  • exists in CAWN, no check is required

IF g_error <> 'X'.

PERFORM sub_check_cabn.

  • Get already uploaded characteristic values (Character, date, time)
    PERFORM sub_get_cuvtab_valc.
  • Get already uploaded characteristic values (Numeric)
    PERFORM sub_get_cuvtab_valn.
  • Find table name and characteristic names
    PERFORM sub_validate_table_fields.
  • Check if all characteristics of table are defined in file
    PERFORM sub_charac_exist.
  • Validate characteristic values
    PERFORM sub_validate_charac_values.

ENDIF.
**********************************************************************
*MOD-009
**********************************************************************
ENDIF.
**********************************************************************
*MOD-009
**********************************************************************

ENDFORM. " SUB_CONVERT_TRANSACTION
&---------------------------------------------------------------------
*& Form SUB_CREATE_IDOCS
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CREATE_IDOCS .

CONSTANTS: C_VTMMAS TYPE EDI_MESTYP VALUE 'VTMMAS'.
CONSTANTS: C_EDI_DC40(8) TYPE C VALUE 'EDI_DC40'.
CONSTANTS: C_2(1) TYPE C VALUE '2'.
CONSTANTS: C_LS(2) TYPE C VALUE 'LS'.
CONSTANTS: C_VTMMAS02(8) TYPE C VALUE 'VTMMAS02'.
CONSTANTS: l_c_x TYPE char1 VALUE 'X'. "#EC NEEDED

  • Local Data Declaration
    DATA: l_logsys TYPE logsys, "#EC NEEDED
    l_i_model TYPE TABLE OF bdi_mmodel, "#EC NEEDED
    l_rec_model TYPE bdi_mmodel, "#EC NEEDED
    l_rec_edidc TYPE edidc, "#EC NEEDED
    l_rec_edidd TYPE edidd, "#EC NEEDED
    l_v_cnt TYPE i VALUE 0. "#EC NEEDED

DATA: wa_i_mmodel type bdi_mmodel. "#EC NEEDED

DATA:
l_text(132), "#EC NEEDED
l_lines TYPE i, "#EC NEEDED
l_idoc_nr_from TYPE i, "#EC NEEDED
l_idoc_nr_to TYPE i, "#EC NEEDED
l_idoc_nr_from_char(10) type c, "#EC *
l_idoc_nr_to_char(10) type c, "#EC *
l_edkp1 LIKE edkp1, "#EC NEEDED
l_edk21 LIKE edk21. "#EC NEEDED

DATA:
l_flg_tranferred_something. "#EC NEEDED

FIELD-SYMBOLS:
. "#EC *

*******************************************************************
*MOD-009
*******************************************************************

  • Getting own logical system
    CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
    own_logical_system = l_logsys
    EXCEPTIONS
    own_logical_system_not_defined = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE i088. "Invalid Logical System
    LEAVE LIST-PROCESSING.
    ENDIF.
  • Getting the systems to which the Idocs are to be sent
    CALL FUNCTION 'MMODEL_INT_VALID_GET'
    EXPORTING
    mestyp = C_VTMMAS
    TABLES
    model = l_i_model.
  • SUBRC check is not required because no exceptions are defined in
  • this FM.
    *******************************************************************
    *MOD-009
    *******************************************************************
  • IF NOT P_SNDPR is initial.
  • SELECT SINGLE * FROM edp21 "#EC *
  • WHERE sndprn = p_sndpr
  • AND mestyp = C_VTMMAS.
  • if sy-subrc = 0.
  • p_mestyp = edp21-mestyp.
  • p_sndprt = edp21-sndprt.
  • endif.
  • ENDIF.

SORT l_i_model by sndsystem mestyp rcvsystem.

READ TABLE l_i_model into wa_i_mmodel with key sndsystem = l_logsys
binary search.
**************************************************
*MOD-008
**************************************************
SORT I_CONTENTTAB1 BY VTNAM.
DELETE I_CONTENTTAB1 where vtnam is initial.
DELETE I_CONTENTTAB1 INDEX 1.
**************************************************
*MOD-008
**************************************************

**************************************************
*MOD-008
**************************************************

loop at i_contentheader1 into wa_contentheader1.
**************************************************
*MOD-008
**************************************************
READ TABLE I_CONTENTTAB1 INTO WA_CONTENTTAB1 WITH KEY VTNAM =
WA_CONTENTHEADER1-VTNAM BINARY SEARCH.
IF SY-SUBRC = 0.
**************************************************
*MOD-008
**************************************************
clear zedidc40.
zedidc40-tabnam = C_EDI_DC40.
zedidc40-docnum = wdocnum. "#EC NEEDED
zedidc40-direct = C_2.
concatenate 'SAP' sy-sysid into zedidc40-rcvpor.
zedidc40-rcvprt = C_LS.

  • zedidc40-rcvprn = 'ID3CLNT800'.
  • zedidc40-rcvprn = p_rcvpr.
    zedidc40-rcvprn = wa_i_mmodel-RCVSYSTEM.
    zedidc40-sndpor = 'SAPT90'.
    zedidc40-sndprt = C_LS.
  • zedidc40-sndprn = 'T90CLNT090'.
    zedidc40-sndprn = l_logsys.
    zedidc40-credat = sy-datum.
    zedidc40-cretim = sy-uzeit.
    zedidc40-mestyp = C_VTMMAS.
    zedidc40-idoctyp = C_VTMMAS02.
    append zedidc40.
    clear: wa_contentheader1.
    clear: wa_contenttab1.
    ENDIF.
    endloop.
    **************************************************
    *MOD-008
    **************************************************

READ TABLE zedidc40 INDEX 1.

IF SY-SUBRC = 0.
l_edkp1-mandt = sy-mandt.
l_edkp1-parnum = zedidc40-sndprn.
l_edkp1-partyp = zedidc40-sndprt.
CALL FUNCTION 'EDI_AGREE_PARTNER_READ' "#EC *
EXPORTING
rec_edkp1 = l_edkp1.
IF sy-subrc <> 0. "#EC *
MESSAGE i810(/sapdmc/lsmw) WITH zedidc40-sndprn
zedidc40-sndprt.
EXIT.
ENDIF.

l_edk21-mandt = sy-mandt.
l_edk21-sndprn = zedidc40-sndprn.
l_edk21-sndprt = zedidc40-sndprt.
l_edk21-mestyp = zedidc40-mestyp.
l_edk21-mescod = zedidc40-mescod.
CALL FUNCTION 'EDI_AGREE_IN_MESSTYPE_READ' "#EC *
EXPORTING
rec_edk21 = l_edk21.
IF sy-subrc <> 0. "#EC *
MESSAGE i811(/sapdmc/lsmw) WITH zedidc40-mestyp.
EXIT.
ENDIF.
ENDIF.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "#EC *
EXPORTING
text = text-010.

if p_proc = c_x.
wdocnum = 0.
LOOP AT zedidc40.
call function 'IDOC_INBOUND_ASYNCHRONOUS'
TABLES
idoc_control_rec_40 = zedidc40

  • idoc_control_rec_40 = gt_curr_edi_dc40
    idoc_data_rec_40 = gt_curr_edi_dd40.
    add 1 to g_cnt_transactions_transferred.
    add 1 to g_cnt_transactions_read.
    add 1 to wdocnum.
    endloop.
    skip 2.
    endif.

DESCRIBE TABLE zedidc40 LINES l_lines.
ADD l_lines TO g_cnt_records_transferred.
DESCRIBE TABLE gt_curr_edi_dd40 LINES l_lines.
ADD l_lines TO g_cnt_records_transferred.

CLEAR:
g_cnt_idocs_package,
zedidc40[],
ZEDIDD40[].

CLEAR:
ZEDIDD40[], "YOG190700
ZEDIDD40[]. "YOG190700

CLEAR g_segnum.

ENDFORM. " SUB_CREATE_IDOCS
&---------------------------------------------------------------------
*& Form SUB_START_IDOC_PROCESS
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_START_IDOC_PROCESS .

CONSTANTS: C_I(1) TYPE C VALUE 'I'.
CONSTANTS: C_EQ(2) TYPE C VALUE 'EQ'.
CONSTANTS: C_VTMMAS(6) TYPE C VALUE 'VTMMAS'.

  • RBDAPP01 aufrufen
    R_CREDAT-SIGN = C_I.
    R_CREDAT-OPTION = C_EQ.
    R_CREDAT-LOW = SY-DATUM.
    APPEND R_CREDAT.

R_CRETIM-SIGN = C_I.
R_CRETIM-OPTION = C_EQ.
R_CRETIM-LOW = SY-UZEIT.
APPEND R_CRETIM.

R_MESTYP-SIGN = C_I.
R_MESTYP-OPTION = C_EQ.
R_MESTYP-LOW = C_VTMMAS.
APPEND R_MESTYP.

LOOP AT zedidc40.
R_SNDPRT-SIGN = C_I.
R_SNDPRT-OPTION = C_EQ.
R_SNDPRT-LOW = zedidc40-sndprt.
APPEND R_SNDPRT.

R_SNDPRN-SIGN = C_I.
R_SNDPRN-OPTION = C_EQ.
R_SNDPRN-LOW = zedidc40-sndprn.
APPEND R_SNDPRN.
ENDLOOP.

SUBMIT RBDAPP01 "#EC CI_SUBMIT
WITH CREDAT IN R_CREDAT
WITH CRETIM IN R_CRETIM
WITH MESTYP IN R_MESTYP
WITH SNDPRN IN R_SNDPRN
WITH SNDPRT IN R_SNDPRT
VIA SELECTION-SCREEN
AND RETURN.

  • Rufe RBDINPUT
    R_MESTYP-SIGN = C_I.
    R_MESTYP-OPTION = C_EQ.
    R_MESTYP-LOW = L_MESSTYPE.
    APPEND R_MESTYP.

SUBMIT RBDINPUT "#EC CI_SUBMIT
VIA SELECTION-SCREEN
AND RETURN.

**CALL TRANSACTION 'WE02'
SUBMIT RSEIDOC2 "#EC CI_SUBMIT
WITH CREDAT EQ R_CREDAT-LOW SIGN C_I

  • WITH DOCNUM EQ GT_ITAB_WA-DOCNUM SIGN 'I'
    AND RETURN.

ENDFORM. " SUB_START_IDOC_PROCESS
&---------------------------------------------------------------------
*& Form SUB_UPLOAD_FROM_APPSERVER
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_UPLOAD_FROM_APPSERVER .

open dataset p_fname for input in text mode encoding default.
if sy-subrc = 0.
DO.
READ DATASET p_fname INTO wa_input_data.
IF sy-subrc NE 0.
IF g_cnt_input_recs = 0.
MESSAGE i242.
g_flg_error = C_Y.
STOP.
ENDIF.
EXIT.
ELSE.
APPEND wa_input_data to i_input_data.
ADD 1 TO g_cnt_input_recs.
CLEAR: wa_input_data.
ENDIF.
ENDDO.
else.
message e246 with text-003.
endif.
close dataset p_fname.

open dataset p_fname1 for input in text mode encoding default.
if sy-subrc = 0.
DO.
READ DATASET p_fname1 INTO wa_input_data1.
IF sy-subrc NE 0.
IF g_cnt_input_recs = 0.

  • MESSAGE s000 WITH 'Input file is empty'.
    MESSAGE i242.
    g_flg_error = C_Y.
    STOP.
    ENDIF.
    EXIT.
    ELSE.
    APPEND wa_input_data1 to i_input_data1.
    ADD 1 TO g_cnt_input_recs.
    CLEAR: wa_input_data1.
    ENDIF.
    ENDDO.
    else.
    message e246 with text-003.
    endif.
    close dataset p_fname1.

delete i_input_data index 1.

delete i_input_data1 INDEX 1.

loop at i_input_data INTO WA_INPUT_DATA.
SPLIT wa_input_data AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO wa_contenthd-vtnam
wa_contenthd-flag.

append wa_contenthd to i_contentheader1.
clear: wa_contenthd.
endloop.

loop at i_input_data1 INTO WA_INPUT_DATA1.
SPLIT wa_input_data1 AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO wa_content1-VTNAM
wa_content1-CHAR1
wa_content1-CHAR2
wa_content1-CHAR3
wa_content1-CHAR4
wa_content1-CHAR5
wa_content1-CHAR6
wa_content1-CHAR7
wa_content1-CHAR8
wa_content1-CHAR9
wa_content1-CHAR10
wa_content1-CHAR11
wa_content1-CHAR12
wa_content1-CHAR13
wa_content1-CHAR14
wa_content1-CHAR15
wa_content1-FLAG.
append wa_content1 to i_contenttab1.
clear: wa_content1.
endloop.

ENDFORM. " SUB_UPLOAD_FROM_APPSERVER
&---------------------------------------------------------------------
*& Form SUB_UPLOAD_FROM_PRESERVER
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_UPLOAD_FROM_PRESERVER .

CONSTANTS: C_ASC(10) TYPE C VALUE 'ASC'. "#EC NEEDED

  • Read file from NT server into a table
    file = p_inpt.

call function 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = i_input_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.

if sy-subrc ne 0.
write: / text-036:, p_inpt.
skip 2.
stop.
endif.

  • Read file from NT server into a table
    CLEAR: file.
    file = p_inpt1.

call function 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = i_input_data1
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.

if sy-subrc ne 0.
write: / text-036:, p_inpt.
skip 2.
stop.
endif.

delete i_input_data INDEX 1.
delete i_input_data1 index 1.

loop at i_input_data into wa_input_data.
SPLIT wa_input_data AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO wa_contenthd-vtnam
wa_contenthd-flag.
append wa_contenthd to i_contentheader1.
clear: wa_contenthd.
endloop.

loop at i_input_data1 into wa_input_data1.
SPLIT wa_input_data1 AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO wa_content1-VTNAM
wa_content1-CHAR1
wa_content1-CHAR2
wa_content1-CHAR3
wa_content1-CHAR4
wa_content1-CHAR5
wa_content1-CHAR6
wa_content1-CHAR7
wa_content1-CHAR8
wa_content1-CHAR9
wa_content1-CHAR10
wa_content1-CHAR11
wa_content1-CHAR12
wa_content1-CHAR13
wa_content1-CHAR14
wa_content1-CHAR15
wa_content1-FLAG.
append wa_content1 to i_contenttab1.
clear: wa_content1.
endloop.

ENDFORM. " SUB_UPLOAD_FROM_PRESERVER
&---------------------------------------------------------------------
*& Form SUB_FINAL_MESSAGE_IDOC
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_FINAL_MESSAGE_IDOC .

DATA:
l_tabix LIKE sy-tabix, "#EC NEEDED
l_filename_read TYPE tumls_filename, "#EC NEEDED
l_filename_conv TYPE tumls_filename. "#EC NEEDED

DATA:
l_cnt_records_read(10) type c, "#EC NEEDED
l_cnt_transactions_read(10) type c, "#EC NEEDED
l_cnt_records_transferred(10) type c, "#EC NEEDED
l_cnt_transactions_transferred(10) type c. "#EC NEEDED

DATA:
l_messagetext(130), "#EC NEEDED
wa_errortab TYPE type_errorline. "#EC NEEDED

l_cnt_records_read = g_cnt_records_read.
l_cnt_transactions_read = g_cnt_transactions_read.
l_cnt_records_transferred = g_cnt_records_transferred.
l_cnt_transactions_transferred = g_cnt_transactions_transferred.

WRITE: / 'DATE:', sy-datum DD/MM/YYYY,
'-',
'TIME:', sy-uzeit USING EDIT MASK '_::_ h'.

ULINE.

ULINE.

WRITE: / 'Inbound Idoc Creation Variant Table'(002). "#EC *

****************************************************************
*MOD-009
****************************************************************

  • ULINE.
    *
  • WRITE: / 'Transactions Read.'(024), "#EC *
  • 30 g_cnt_transactions_read.
  • WRITE: / 'Transactions Transferred:'(026), "#EC *
  • 30 g_cnt_transactions_transferred.
  • WRITE: / 'Records Transferred:'(027), "#EC *
  • 30 g_cnt_records_transferred.
    *
  • ULINE.
    ****************************************************************
    *MOD-009
    ****************************************************************

*****************************************************
*MOD-008
*****************************************************

  • IF NOT g_error_tab IS INITIAL.
  • LOOP AT g_error_tab INTO wa_errortab.
  • AT NEW msgty.
  • CASE wa_errortab-msgty.
  • WHEN 'E'.
  • SKIP.
  • WRITE / icon_message_critical AS ICON .
  • WHEN 'I'.
  • SKIP.
  • WRITE / icon_green_light AS ICON .
  • WHEN 'S'.
  • SKIP.
  • WRITE / icon_red_light AS ICON .
  • WHEN 'W'.
  • SKIP.
  • WRITE / icon_yellow_light AS ICON .
  • WHEN 'A'.
  • SKIP.
  • WRITE / icon_alert AS ICON .
  • WHEN 'X'.
  • SKIP.
  • WRITE / icon_action_fault AS ICON .
  • WHEN OTHERS.
  • usually can't happen
  • SKIP.
  • WRITE / icon_message_critical AS ICON .
  • wa_errortab-msgty = 'E'.
  • MODIFY g_error_tab FROM wa_errortab.
  • ENDCASE.
  • ENDAT.
  • AT NEW par1.
  • WRITE: /
  • '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ',
  • '- - - - - - - - - - - - - - - - - '.
  • ENDAT.
  • AT NEW par2.
  • SKIP.
  • ENDAT.
  • MESSAGE ID wa_errortab-id
  • TYPE wa_errortab-msgty
  • NUMBER wa_errortab-msgno
  • WITH wa_errortab-par1 wa_errortab-par2
  • wa_errortab-par3 wa_errortab-par4
  • INTO l_messagetext.
  • WRITE l_messagetext.
  • ENDLOOP.
  • SKIP.
  • ULINE.
  • ENDIF.
    *****************************************************
    *MOD-008
    *****************************************************

ENDFORM. " SUB_FINAL_MESSAGE_IDOC
&---------------------------------------------------------------------
*& Form SUB_DISPLAY_VARIANT
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_DISPLAY_VARIANT .

IF NOT i_cuv_error IS INITIAL.
SKIP 2.

  • WRITE:/ 'Following tables have incorrect characteristic names'(013).
    "#EC NOTEXT
    WRITE:/ text-013. "#EC NOTEXT

WRITE:/ sy-uline(72).
FORMAT COLOR 1 ON.
WRITE:/1 sy-vline,
2 text-014, "#EC NOTEXT
20 sy-vline,
21 text-015, "#EC NOTEXT
72 sy-vline.
FORMAT COLOR 1 OFF.
WRITE:/ sy-uline(72).
LOOP AT i_cuv_error INTO wa_vtnam.
WRITE:/1 sy-vline,
2 wa_vtnam-vtnam,
20 sy-vline,
21 wa_vtnam-reas,
72 sy-vline.
WRITE:/ sy-uline(72).
ENDLOOP.
ENDIF.

ENDFORM. " SUB_DISPLAY_VARIANT
&---------------------------------------------------------------------
*& Form SUB_DISPLAY_ERRORLINES
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_DISPLAY_ERRORLINES .

SKIP 2.
IF NOT i_error IS INITIAL.
FORMAT COLOR 1 ON.

  • WRITE:/ 'Following lines have invalid/blank values'. "#EC NOTEXT
    WRITE:/ text-016. "#EC NOTEXT

SKIP.
WRITE:/ sy-uline(120).
WRITE:/1 sy-vline,
2 'Variant table'(017), "#EC NOTEXT
20 sy-vline,
21 'Fieldname'(018), "#EC NOTEXT
51 sy-vline,
52 'Characteristic name'(019), "#EC NOTEXT
82 sy-vline,
83 'Characteristic value'(020), "#EC NOTEXT
113 sy-vline,
114 'Row no'(021), "#EC NOTEXT
120 sy-vline.
FORMAT COLOR 1 OFF.
WRITE:/ sy-uline(120).
LOOP AT i_error INTO wa_error.
WRITE:/1 sy-vline,
2 wa_error-vtnam,
20 sy-vline,
21 wa_error-fname+8(6),
51 sy-vline,
52 wa_error-atnam,
82 sy-vline,
83 wa_error-atwrt,
113 sy-vline,
114 wa_error-row,
120 sy-vline.
WRITE:/ sy-uline(120).
ENDLOOP.
ENDIF.

ENDFORM. " SUB_DISPLAY_ERRORLINES

**&---------------------------------------------------------------------
*
*& Form SUB_CLEAR_SOURCE_TABLES
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CLEAR_SOURCE_TABLES .

Refresh: I_CONTENTHEADER1,
I_CONTENTTAB1.

****************************

  • REFRESH GLOBAL WORK AREAS
    ****************************

*Work Area for the structure I_MESSTAB
CLEAR: wa_vartab,
wa_vartabdate,
wa_vardetails,
wa_tabinput,
wa_dsninput,
wa_dsninput,
wa_newinput,
wa_gnewinput,
wa_ginput_data ,
wa_final,
wa_content,
wa_contenthd ,
wa_contentheader,
wa_contenttab,
wa_content1,
wa_contenthd1,
wa_contentheader1,
wa_contenttab1,
wa_E1CUVTM ,
wa_E1CUV1M ,
wa_E1DATEM .

*************************************************

  • REFRESH INTERNAL TABLES AND WORK AREAS FOR BDC
    *************************************************

*Internal Table to store the data to display the error message
REFRESH i_errormsg[] .

*Internal Table to store the data to display the error message
REFRESH i_error[].

**Work area to store the data to display the error message
CLEAR wa_errormsg.

*Internal table which will store data for the error log
REFRESH i_error_log[] .

***************************

  • REFRESH GLOBAL VARIABLES
    ***************************
    CLEAR: g_ctr_input_recs,
    g_ctr_output_recs,
    g_msg,
    g_struct_file,
    g_login,
    g_phyin ,
    g_FNAME1,
    g_repid,
    g_exit,
    gx_variant,
    g_lines ,
    g_save,
    g_splid ,
    p_login ,
    p_phyin.

*************************************************

  • REFRESH GLOBAL INTERNAL TABLES FOR ALV DISPLAY
    *************************************************
    *Refresh Internal tables for ALV Field cat
    REFRESH i_fieldcat_ov[].
    REFRESH i_fieldcat_dtl[].
    REFRESH i_fieldcat_ov1[].
    REFRESH i_events[].

Refresh: zedidc40,
zedidd40,
gt_curr_edi_dc40,
gt_curr_edi_dd40.

CLEAR: i_file,
i_file_tmp,
i_cuvtab_fld,
i_cuvtab_valn,
i_cuvtab,
i_cuvtab_valc,
i_col_pos,
g_slnid_c,
g_slnid_n,
g_split_var.

ENDFORM. " SUB_CLEAR_SOURCE_TABLES
&---------------------------------------------------------------------
*& Form SUB_CLEAR_TABLES
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CLEAR_TABLES .

Refresh: zedidc40,
zedidd40,
gt_curr_edi_dc40,
gt_curr_edi_dd40.

CLEAR: i_file,
i_file_tmp,
i_cuvtab_fld,
i_cuvtab_valn,
i_cuvtab,
i_cuvtab_valc,
i_col_pos,
g_slnid_c,
g_slnid_n,
g_split_var.

ENDFORM. " SUB_CLEAR_TABLES
&---------------------------------------------------------------------
*& Form SUB_CONVERT_0001
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CONVERT_0001 .

constants: c_01(2) type c value '01'.

clear ze1cuvtm.
clear zedidd40.
wdocnum = wdocnum + 1.
ze1cuvtm-msgfn = c_009.
if not wa_contentheader1-vtnam is initial.
ZE1CUVTM-VAR_TAB = wa_contentheader1-vtnam.
endif.

zedidd40-docnum = wdocnum. "#EC NEEDED
zedidd40-segnum = c_000001.
zedidd40-segnam = 'E2CUVTM001'.
zedidd40-psgnum = '000000'.

  • zedidd40-segnam = c_E1CUVTM.
    zedidd40-hlevel = c_01.
    zedidd40-sdata = ze1cuvtm.
    append zedidd40.

perform transfer_record_idoc.

ENDFORM. " SUB_CONVERT_0001
&---------------------------------------------------------------------
*& Form SUB_CONVERT_0002
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CONVERT_0002 .
  • ze1datem
    witemno = witemno + 1. "#EC NEEDED
    wsegnum = wsegnum + 1. "#EC NEEDED
    clear ze1datem.
    ze1datem-msgfn = c_009.
    ze1datem-key_date = sy-datum.

zedidd40-segnam = 'E2DATEM001'.
zedidd40-segnum = '0002'.
zedidd40-psgnum = '000001'.
*******************************************
*MOD-009
*******************************************

  • zedidd40-hlevel = '02'.
  • zedidd40-docnum = wdocnum. "#EC NEEDED
  • zedidd40-segnum = wsegnum.
  • zedidd40-segnam = c_E1DATEM.
    *******************************************
    *MOD-009
    *******************************************
    zedidd40-hlevel = c_02.
    zedidd40-sdata = ze1datem.
    append zedidd40. " E1DATEM
    witemno = 0. "#EC NEEDED
    witemno_gst = 0. "#EC NEEDED
    witemno_qst = 0. "#EC NEEDED
    witemno_new = 0. "#EC NEEDED
    wsegnum = 1. "#EC NEEDED

perform transfer_record_idoc.

ENDFORM. " SUB_CONVERT_0002
&---------------------------------------------------------------------
*& Form SUB_CONVERT_0003
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CONVERT_0003 .

perform sub_store_file.

ENDFORM. " SUB_CONVERT_0003
&---------------------------------------------------------------------
*& Form SUB_GET_CUVTAB
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CUVTAB .

CLEAR g_error.

LOOP AT I_CONTENTHEADER1 INTO WA_CONTENTHEADER1.
SELECT vtint vtnam FROM cuvtab
INTO CORRESPONDING FIELDS OF TABLE i_cuvtab
WHERE vtnam = wa_contentheader1-vtnam.
IF sy-subrc <> 0.
g_error = c_x.
CLEAR wa_vtnam.
wa_vtnam-vtnam = wa_contentheader1-vtnam.
wa_vtnam-reas = text-008.
APPEND wa_vtnam TO i_cuv_error.
wa_errortab-msgty = 'E'.
wa_errortab-id = '/factglb/gta_custdev'.
wa_errortab-msgno = 001.
wa_errortab-par1 = wa_vtnam-reas.
INSERT wa_errortab INTO TABLE g_error_tab.
clear: wa_vtnam, wa_errortab.
ENDIF.
clear: WA_CONTENTHEADER1.
ENDLOOP.

ENDFORM. " SUB_GET_CUVTAB
&---------------------------------------------------------------------
*& Form SUB_GET_VNT_MA
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_VNT_MA .

constants: c_e(1) TYPE c value 'E',
C_001(3) TYPE C VALUE '001'.

CLEAR wa_vnt_ma.

LOOP AT I_CONTENTHEADER1 INTO WA_CONTENTHEADER1.

SELECT SINGLE vtnam unique_no no_chr
FROM ZDVNT_MA
INTO wa_vnt_ma
WHERE vtnam = wa_contentheader1-vtnam.

IF sy-subrc <> 0.
g_error = 'X'.
CLEAR wa_vtnam.
wa_vtnam-vtnam = wa_contentheader1-vtnam.
wa_vtnam-error = c_x.
wa_vtnam-reas = text-023 . "#EC NOTEXT
APPEND wa_vtnam TO i_cuv_error.
wa_errortab-msgty = c_e.
wa_errortab-id = '/factglb/gta_custdev'.
wa_errortab-msgno = c_001.
wa_errortab-par1 = wa_vtnam-reas.
INSERT wa_errortab INTO TABLE g_error_tab.
clear: wa_vtnam, wa_errortab.
ENDIF.
clear: wa_contentheader1.

ENDLOOP.

ENDFORM. " SUB_GET_VNT_MA
&---------------------------------------------------------------------
*& Form SUB_GET_CUVTAB_VALN
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CUVTAB_VALN .

IF NOT i_cuvtab[] IS INITIAL.
SELECT vtint slnid atinn val_from
FROM cuvtab_valn INTO TABLE i_cuvtab_valn
FOR ALL ENTRIES IN i_cuvtab
WHERE vtint = i_cuvtab-vtint.

IF sy-subrc = 0.
SORT i_cuvtab_valn BY vtint slnid.
ENDIF.
ENDIF.

ENDFORM. " SUB_GET_CUVTAB_VALN
&---------------------------------------------------------------------
*& Form SUB_GET_CUVTAB_FLD
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CUVTAB_FLD .

IF g_error <> c_x.

IF NOT i_cuvtab[] IS INITIAL.
SELECT vtint atinn vtpos FROM cuvtab_fld
INTO TABLE i_cuvtab_fld
FOR ALL ENTRIES IN i_cuvtab
WHERE vtint = i_cuvtab-vtint.

IF sy-subrc = 0.
SORT i_cuvtab_fld BY vtint atinn.
ELSE.
LOOP AT I_CONTENTHEADER1 INTO WA_CONTENTHEADER1.

Sort i_cuvtab by vtint vtnam.
READ TABLE i_cuvtab INTO wa_vtnam WITH KEY VTNAM =
WA_CONTENTHEADER1-VTNAM BINARY SEARCH.
IF SY-SUBRC = 0.
g_error = c_x.
CLEAR wa_vtnam.
wa_vtnam-vtnam = wa_contentheader1-vtnam.
wa_vtnam-reas = text-009.
APPEND wa_vtnam TO i_cuv_error.
wa_errortab-msgty = c_e.
wa_errortab-id = '/factglb/gta_custdev'.
wa_errortab-msgno = 001.
wa_errortab-par2 = wa_vtnam-reas.
INSERT wa_errortab INTO TABLE g_error_tab.
clear: wa_vtnam, wa_errortab.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.

ENDFORM. " SUB_GET_CUVTAB_FLD
&---------------------------------------------------------------------
*& Form SUB_CHECK_CABN
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CHECK_CABN .

LOOP AT i_cabn ASSIGNING .
READ TABLE i_cawn_i INTO wa_cawn WITH KEY atinn = -atinn.
IF sy-subrc <> 0.
-check = C_X.
ENDIF.
ENDLOOP.

ENDFORM. " SUB_CHECK_CABN
&---------------------------------------------------------------------
*& Form SUB_GET_CUVTAB_VALC
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_GET_CUVTAB_VALC .

IF NOT i_cuvtab[] is initial.
SELECT vtint slnid atinn valc
FROM cuvtab_valc INTO TABLE i_cuvtab_valc
FOR ALL ENTRIES IN i_cuvtab
WHERE vtint = i_cuvtab-vtint.
IF sy-subrc = 0.
SORT i_cuvtab_valc BY vtint slnid.
ENDIF.
ENDIF.

ENDFORM. " SUB_GET_CUVTAB_VALC
&---------------------------------------------------------------------
*& Form SUB_VALIDATE_TABLE_FIELDS
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_VALIDATE_TABLE_FIELDS .

SORT I_FILE_TMP BY VTNAM.
LOOP AT i_cuvtab ASSIGNING .
READ TABLE i_file_tmp INTO wa_file WITH KEY flag = 'X'.

IF sy-subrc <> 0.

  • Row containing characteristic names might have 'x' instead of 'X'
    READ TABLE i_file_tmp INTO wa_file WITH KEY flag = 'x'.
    IF sy-subrc <> 0.
    -error = C_X.
    -reas = text-011. "#EC NOTEXT
    g_error = 'X'.
    CLEAR wa_vtnam.
    wa_vtnam = .
    APPEND wa_vtnam TO i_cuv_error.
    wa_errortab-msgty = C_E.
    wa_errortab-id = '/factglb/gta_custdev'.
    wa_errortab-msgno = 001.
    wa_errortab-par2 = wa_vtnam-reas.
    INSERT wa_errortab INTO TABLE g_error_tab.
    clear: wa_vtnam, wa_errortab.
    EXIT.
    ENDIF.
    ELSE.
  • Check for characteristic name 1
    IF wa_file-char1 IS NOT INITIAL.
    CLEAR wa_cabn.

PERFORM get_internal_char USING wa_file-char1
CHANGING wa_cabn
.

  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.
ENDIF.

CHECK -error IS INITIAL.

  • Check for characteristic name 2
    IF wa_file-char2 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char2
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.
ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 3
    IF wa_file-char3 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char3
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.

  • Check for characteristic name 4
    IF wa_file-char4 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char4
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 5
    IF wa_file-char5 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char5
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 6
    IF wa_file-char6 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char6
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 7
    IF wa_file-char7 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char7
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 8
    IF wa_file-char8 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char8
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 9
    IF wa_file-char9 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char9
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 10
    IF wa_file-char10 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char10
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 11
    IF wa_file-char11 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char11
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 12
    IF wa_file-char12 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char12
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 13
    IF wa_file-char13 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char13
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 14
    IF wa_file-char14 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char14
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
CHECK -error IS INITIAL.

  • Check for characteristic name 15
    IF wa_file-char15 IS NOT INITIAL.
    CLEAR wa_cabn.
    PERFORM get_internal_char USING wa_file-char15
    CHANGING wa_cabn
    .
  • Find out if characteristic name exists in variant table definitio
    PERFORM find_char_exist USING wa_file

wa_cabn.

ENDIF.
ENDIF.
ENDLOOP.

ENDFORM. " SUB_VALIDATE_TABLE_FIELDS
&---------------------------------------------------------------------
*& Form SUB_CHARAC_EXIST
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CHARAC_EXIST .

IF g_error <> 'X'.

LOOP AT i_cuvtab_fld INTO wa_cuvtab_fld WHERE exist = space.
g_error = 'X'.
CLEAR wa_vtnam.
READ TABLE i_cuvtab INTO wa_vtnam WITH KEY
vtint = wa_cuvtab_fld-vtint.

  • No need to check sy-subrc here
    READ TABLE i_cabn INTO wa_cabn WITH KEY atinn =
    wa_cuvtab_fld-atinn.
  • No need to check sy-subrc here

CONCATENATE wa_cabn-atnam text-022 "#EC NOTEXT
INTO wa_vtnam-reas SEPARATED BY space.
APPEND wa_vtnam TO i_cuv_error.
wa_errortab-msgty = C_E.
wa_errortab-id = '/factglb/gta_custdev'.
wa_errortab-msgno = 001.
wa_errortab-par1 = wa_vtnam-reas.
INSERT wa_errortab INTO TABLE g_error_tab.
clear: wa_vtnam, wa_errortab.
ENDLOOP.
ENDIF.

ENDFORM. " SUB_CHARAC_EXIST
&---------------------------------------------------------------------
*& Form SUB_VALIDATE_CHARAC_VALUES
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_VALIDATE_CHARAC_VALUES .

LOOP AT i_cuvtab INTO wa_vtnam WHERE error <> c_x.
CLEAR i_dupl_file. "A

  • Clear internal table for duplicate entries
    CLEAR i_dupl.
  • Transfer already stored characteristic values (CHAR, DATE and TIME)
    PERFORM sub_transfer_st_char.
  • Transfer already stored characteristic values (Numeric)
    PERFORM sub_transfer_st_num.
  • Check if Internal table for duplicate records is populated or not
    IF NOT i_dupl IS INITIAL.
    SORT i_dupl BY vtnam char1 char2 char3
    char4 char5 char6 char7
    char8 char9 char10 char11
    char12 char13 char14 char15.
    ENDIF.

SORT i_col_pos BY vtint
vtnam
atinn
atnam.

  • Check current sequence number for SLNID
  • We would only use G_SLNID_C from here onwards for sequnce purpose
    IF g_slnid_c < g_slnid_n.
    g_slnid_c = g_slnid_n.
    ENDIF.

LOOP AT i_file INTO wa_file WHERE vtnam = wa_vtnam-vtnam.
CLEAR wa_dupl_file.

CLEAR i_e1cuv1m.

  • Increment Sequence counter for each record
    g_slnid_c = g_slnid_c + 1.
  • Increment Sequnce counter for concatenation
    g_split_var = g_split_var + 1.
  • Counter for each row
    g_row = g_row + 1.
    CLEAR g_invalid.
    *******************************************
    *MOD-008
    *******************************************
    PERFORM sub_check_char_values.
    *******************************************
    *MOD-008
    *******************************************
  • Check for duplicate values
    READ TABLE i_dupl INTO wa_dupl
    WITH KEY vtnam = wa_dupl_file-vtnam
    char1 = wa_dupl_file-char1
    char2 = wa_dupl_file-char2
    char3 = wa_dupl_file-char3
    char4 = wa_dupl_file-char4
    char5 = wa_dupl_file-char5
    char6 = wa_dupl_file-char6
    char7 = wa_dupl_file-char7
    char8 = wa_dupl_file-char8
    char9 = wa_dupl_file-char9
    char10 = wa_dupl_file-char10
    char11 = wa_dupl_file-char11
    char12 = wa_dupl_file-char12
    char13 = wa_dupl_file-char13
    char14 = wa_dupl_file-char14
    char15 = wa_dupl_file-char15.

IF sy-subrc = 0.
g_invalid = 'X'.

  • Reduce counter by 1 to maintain sequence
    g_split_var = g_split_var - 1.
    ELSE.
    CLEAR wa_dupl.
    wa_dupl = wa_dupl_file.
    APPEND wa_dupl TO i_dupl.
    CLEAR wa_dupl.
    ENDIF.

*******************************************************************
**MOD-009
*******************************************************************

  • IF sy-subrc = 0.
  • g_invalid = c_x.
    • Reduce counter by 1 to maintain sequence
  • g_split_var = g_split_var - 1.
  • ELSE.
  • CLEAR wa_dupl.
  • wa_dupl = wa_dupl_file.
  • APPEND wa_dupl TO i_dupl.
  • CLEAR wa_dupl.
  • ENDIF.
    *
    *******************************************************************
    **MOD-009
    *******************************************************************

******************************************************************
*MOD-009
******************************************************************
IF g_invalid IS INITIAL.
LOOP AT i_e1cuv1m INTO wa_e1cuv1m.

  • perform fill_edidd_segments USING wa_e1cuv1m.
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m. "#EC *
    ENDLOOP.
    ENDIF.
    ******************************************************************
    *MOD-009
    ******************************************************************
    ENDLOOP.
    ENDLOOP.

ENDFORM. " SUB_VALIDATE_CHARAC_VALUES
&---------------------------------------------------------------------
*& Form SUB_TRANSFER_ST_CHAR
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_TRANSFER_ST_CHAR .

DATA: l_lines TYPE i.

LOOP AT i_cuvtab_valc INTO wa_cuvtab_valc
WHERE vtint = wa_vtnam-vtint.
CLEAR wa_cabn.
READ TABLE i_cabn_atinn INTO wa_cabn
WITH KEY atinn = wa_cuvtab_valc-atinn BINARY SEARCH.

  • No need to check sy-subrc here
    CLEAR wa_e1cuv1m.
    wa_e1cuv1m-msgfn = c_009.
    wa_e1cuv1m-vtlineno5 = wa_cuvtab_valc-slnid.
    wa_e1cuv1m-vtcharact = wa_cabn-atnam.
    wa_e1cuv1m-atwrt = wa_cuvtab_valc-valc.
    ****************************************************
    *MOD-008
    ****************************************************
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m. "#EC *
    ****************************************************
    *MOD-008
    ****************************************************
  • store last value
    g_slnid_c = wa_cuvtab_valc-slnid.
  • Find concatenated number at the end of variant
    IF wa_cabn-atnam = c_varcond.
    CLEAR i_split.
    SPLIT wa_cuvtab_valc-valc AT '_' INTO TABLE i_split.
    CLEAR l_lines.

DESCRIBE TABLE i_split LINES l_lines.

  • Read last line of table as it contains concatenated number
    READ TABLE i_split INTO wa_split INDEX l_lines.
    SHIFT wa_split-f1 LEFT DELETING LEADING space.
    IF wa_split-f1 CO '0123456789 '.
    CLEAR l_lines.
    l_lines = wa_split-f1.
    IF l_lines > g_split_var.
    g_split_var = l_lines.
    ENDIF.
    ENDIF.
    ENDIF.
  • Check for duplicate records
    PERFORM pop_dupl USING wa_vtnam-vtnam
    g_slnid_c
    wa_cabn-atnam
    wa_cuvtab_valc-valc.

ENDLOOP.

ENDFORM. " SUB_TRANSFER_ST_CHAR
&---------------------------------------------------------------------
*& Form SUB_TRANSFER_ST_NUM
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_TRANSFER_ST_NUM .

DATA: l_val TYPE p, "#EC NEEDED
l_val1 TYPE p DECIMALS 1, "#EC NEEDED
l_val2 TYPE p DECIMALS 2, "#EC NEEDED
l_val3 TYPE p DECIMALS 3, "#EC NEEDED
l_char TYPE char16. "#EC NEEDED

LOOP AT i_cuvtab_valn INTO wa_cuvtab_valn
WHERE vtint = wa_vtnam-vtint.
CLEAR wa_cabn.
READ TABLE i_cabn_atinn INTO wa_cabn
WITH KEY atinn = wa_cuvtab_valn-atinn BINARY SEARCH.

CLEAR wa_e1cuv1m.
wa_e1cuv1m-msgfn = c_009.
wa_e1cuv1m-vtlineno5 = wa_cuvtab_valn-slnid.
wa_e1cuv1m-vtcharact = wa_cabn-atnam.
wa_e1cuv1m-atflv = wa_cuvtab_valn-val_from.

****************************************************
*MOD-008
****************************************************
PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m. "#EC *
****************************************************
*MOD-008
****************************************************

  • store last value
    g_slnid_n = wa_cuvtab_valn-slnid.
  • Convert characteristic value from Exp format to normal format
    CLEAR: l_val, l_char, l_val1, l_val2, l_val3.
    CASE wa_cabn-anzdz.
    WHEN 0.
    l_val = wa_cuvtab_valn-val_from.
    l_char = l_val.
    WHEN 1.
    l_val1 = wa_cuvtab_valn-val_from.
    l_char = l_val1.
    WHEN 2.
    l_val2 = wa_cuvtab_valn-val_from.
    l_char = l_val2.
    WHEN 3.
    l_val = wa_cuvtab_valn-val_from.
    l_char = l_val.

ENDCASE.

SHIFT l_char LEFT DELETING LEADING space.

  • Check for duplicate records
    PERFORM pop_dupl USING wa_vtnam-vtnam
    g_slnid_n
    wa_cabn-atnam
    l_char.

ENDLOOP.

ENDFORM. " SUB_TRANSFER_ST_NUM
&---------------------------------------------------------------------
*& Form SUB_CHECK_CHAR_VALUES
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CHECK_CHAR_VALUES .

DATA: l_fieldname TYPE fieldname,
l_field_dup TYPE fieldname.
FIELD-SYMBOLS: TYPE ANY,
TYPE ANY.

DATA: l_len_slnid TYPE i, "#EC NEEDED
l_len_varcond TYPE i, "#EC NEEDED
l_temp_slnid TYPE i, "#EC NEEDED
l_temp_slnc TYPE char5, "#EC NEEDED
l_temp_varcond TYPE varcond, "#EC NEEDED
l_sub_var TYPE i, "#EC NEEDED
l_val_split TYPE char10. "#EC NEEDED

DATA: l_invalid. "#EC NEEDED

  • We are sorting it to concatenate characteristics value into Variant
    CLEAR g_varcond.
    CONCATENATE 'V' wa_vnt_ma-unique_no INTO g_varcond.

LOOP AT i_col_pos INTO wa_col_pos WHERE vtnam = wa_file-vtnam.
CLEAR l_fieldname.

  • Dynamically assign value to field l_value for validation
    CONCATENATE 'WA_FILE-CHAR' wa_col_pos-field INTO l_fieldname.
    ASSIGN (l_fieldname) TO .
  • Put values in work area to check for duplicates
    IF wa_col_pos-atnam <> c_varcond. " Variant condition
    CLEAR l_field_dup.
    wa_dupl_file-vtnam = wa_file-vtnam.
    CONCATENATE 'WA_DUPL_FILE-CHAR' wa_col_pos-field INTO l_field_dup.
    ASSIGN (l_field_dup) TO .
    ************************************************
    *MOD-008
    ************************************************
  • = .
    IF NOT is initial.
    ASSIGN TO .
    ENDIF.
    ************************************************
    *MOD-008
    ************************************************
    CONCATENATE g_varcond INTO g_varcond SEPARATED BY '_'.
  • ENDIF commented out, It will be taken to the end just before endloop
  • Value for Z_VARCOND will be generated by program as per new logic
  • ENDIF.
    IF IS NOT INITIAL.
    SORT I_CABN BY ATINN ATNAM.
    CLEAR wa_cabn.
    READ TABLE i_cabn INTO wa_cabn
    WITH KEY atnam = wa_col_pos-atnam. " BINARY SEARCH.
  • Validate values against function module stored in field ATPRF
    CLEAR l_invalid.
    IF wa_cabn-atprf IS NOT INITIAL.
    CATCH SYSTEM-EXCEPTIONS OTHERS = 1.
    CALL FUNCTION wa_cabn-atprf
    EXPORTING
    charact_no = wa_cabn-atinn
    charact = wa_cabn-atnam
    value =
    EXCEPTIONS
    not_found = 1.

IF sy-subrc <> 0.
l_invalid = c_x.
g_invalid = c_x.
ENDIF.
ENDCATCH.
ENDIF.

IF l_invalid <> c_x.

  • SY-SUBRC should not fail here because check has already been done
  • We need to validate value only if following fields are blank
    IF wa_cabn-atson IS INITIAL " Indicator: Additional Values
    AND wa_cabn-atprt IS INITIAL " Check table
    AND wa_cabn-atprr IS INITIAL " Name of Check Report Program
    AND wa_cabn-atprf IS INITIAL " Function Module for Checking
    AND wa_cabn-check IS INITIAL. " No value found in CAWN table
  • Check value
    CLEAR wa_cawn.

CASE wa_cabn-atfor.
WHEN c_char OR c_date OR c_time.
READ TABLE i_cawn_c INTO wa_cawn WITH KEY atinn =
wa_cabn-atinn
atwrt =
.
IF sy-subrc = 0.
IF wa_cawn-lkenz = c_x.
PERFORM errror_line USING wa_file-vtnam
l_fieldname
wa_cabn-atnam

g_row.
g_invalid = c_x.

ELSE.
CLEAR wa_e1cuv1m.
wa_e1cuv1m-msgfn = c_009.
wa_e1cuv1m-vtlineno5 = g_slnid_c.
wa_e1cuv1m-vtcharact = wa_cabn-atnam.
wa_e1cuv1m-atwrt = .
APPEND wa_e1cuv1m TO i_e1cuv1m.
****************************************************
*MOD-008
****************************************************

  • perform fill_edidd_segments USING wa_e1cuv1m.
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m.
    "#EC *
    clear: wa_e1cuv1m.
    ****************************************************
    *MOD-008
    ****************************************************
    ENDIF.
    ELSE.
    PERFORM errror_line USING wa_file-vtnam
    l_fieldname
    wa_cabn-atnam

g_row.
g_invalid = C_X.
ENDIF.
WHEN OTHERS.
************************************************************
*MOD-008
***********************************************************
READ TABLE i_cawn_n INTO wa_cawn WITH KEY atinn =
wa_cabn-atinn
atflv =
.
IF sy-subrc = 0.
IF wa_cawn-lkenz = C_X.
PERFORM errror_line USING wa_file-vtnam
l_fieldname
wa_cabn-atnam

g_row.
g_invalid = C_X.
ELSE.
CLEAR wa_e1cuv1m.
wa_e1cuv1m-msgfn = C_009.
wa_e1cuv1m-vtlineno5 = g_slnid_c.
wa_e1cuv1m-vtcharact = wa_cabn-atnam.
wa_e1cuv1m-atflv = .
APPEND wa_e1cuv1m TO i_e1cuv1m.

*****************************************************
**MOD-008
*****************************************************

  • perform fill_edidd_segments USING wa_e1cuv1m.
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m.
    "#EC *
    clear: wa_e1cuv1m.
    *****************************************************
    **MOD-008
    *****************************************************
    ENDIF.
    ELSE.
    PERFORM errror_line USING wa_file-vtnam
    l_fieldname
    wa_cabn-atnam

g_row.

g_invalid = C_X.
ENDIF.
*************************************************************
*MOD-008
************************************************************
ENDCASE.
ELSE.
CASE wa_cabn-atfor.
WHEN c_char OR c_date OR c_time.
CLEAR wa_e1cuv1m.
wa_e1cuv1m-msgfn = C_009.
wa_e1cuv1m-vtlineno5 = g_slnid_c.
wa_e1cuv1m-vtcharact = wa_cabn-atnam.
wa_e1cuv1m-atwrt = .
APPEND wa_e1cuv1m TO i_e1cuv1m.

****************************************************
*MOD-008
****************************************************

  • perform fill_edidd_segments USING wa_e1cuv1m.
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m.
    "#EC *
    clear: wa_e1cuv1m.
    ****************************************************
    *MOD-008
    ****************************************************
    WHEN OTHERS.
    CLEAR wa_e1cuv1m.
    wa_e1cuv1m-msgfn = C_009.
    wa_e1cuv1m-vtlineno5 = g_slnid_c.
    wa_e1cuv1m-vtcharact = wa_cabn-atnam.
    wa_e1cuv1m-atflv = .
    APPEND wa_e1cuv1m TO i_e1cuv1m.
    ****************************************************
    *MOD-008
    ****************************************************
    PERFORM transfer_e1cuv1m. " USING wa_e1cuv1m. "#EC

clear: wa_e1cuv1m.
****************************************************
*MOD-008
****************************************************

ENDCASE.
ENDIF.
ELSE.

PERFORM errror_line USING wa_file-vtnam
l_fieldname
wa_col_pos-atnam

g_row.

ENDIF.

ELSE.
PERFORM errror_line USING wa_file-vtnam
l_fieldname
wa_col_pos-atnam

g_row.

ENDIF.

ENDIF.

clear: wa_col_pos.
ENDLOOP.

  • Assign value to type i variable to find length
    CLEAR: l_len_slnid,
    l_len_varcond,
    l_temp_slnid,
    l_temp_slnc,
    l_temp_varcond,
    l_sub_var .
  • Put i type value in variable with 10 characters
    CLEAR l_val_split.
    l_val_split = g_split_var.
    SHIFT l_val_split LEFT DELETING LEADING space.
    l_temp_slnid = g_split_var.
    l_temp_slnc = l_val_split+0(5).
  • SHIFT l_temp_slnc LEFT DELETING LEADING space.
    l_len_slnid = STRLEN( l_temp_slnc ).
    l_len_varcond = STRLEN( g_varcond ).
    l_sub_var = 26 - l_len_slnid.
    l_sub_var = l_sub_var - 1.
    l_temp_varcond = g_varcond+0(l_sub_var).
    CLEAR g_varcond.
    CONCATENATE l_temp_varcond l_temp_slnc INTO g_varcond
    SEPARATED BY '_'.
    **************************************************************
    **MOD-009
    **************************************************************
    REFRESH: i_e1cuv1m.
    CLEAR wa_e1cuv1m.
    wa_e1cuv1m-msgfn = C_009.
    wa_e1cuv1m-vtlineno5 = g_slnid_c.
    wa_e1cuv1m-vtcharact = c_varcond.
    wa_e1cuv1m-atwrt = g_varcond.
    APPEND wa_e1cuv1m TO i_e1cuv1m.
    **************************************************************
    **MOD-009
    **************************************************************

ENDFORM. " SUB_CHECK_CHAR_VALUES
&---------------------------------------------------------------------
*& Form SUB_DUPL_COLUMNS
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_DUPL_COLUMNS .

DATA: l_fieldname TYPE fieldname, "#EC NEEDED
l_counter TYPE char2. "#EC NEEDED
FIELD-SYMBOLS: TYPE ANY. "#EC *
CONSTANTS: c_field TYPE char12 VALUE 'WA_FILE-CHAR'. "#EC NEEDED

DO 15 TIMES.
l_counter = l_counter + 1.
CONCATENATE c_field l_counter INTO l_fieldname.
IF l_fieldname IS NOT INITIAL.
ASSIGN (l_fieldname) TO .
IF IS ASSIGNED.
wa_charval-char = .
APPEND wa_charval TO i_charval.
ENDIF.
ENDIF.
ENDDO.

IF i_charval IS NOT INITIAL.
DELETE i_charval WHERE char IS INITIAL.
SORT i_charval.
DELETE ADJACENT DUPLICATES FROM i_charval.
IF sy-subrc = 0.
MESSAGE i243.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.

ENDFORM. " SUB_DUPL_COLUMNS
&---------------------------------------------------------------------
*& Form SUB_STORE_FILE
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_STORE_FILE .

MOVE-CORRESPONDING wa_contenttab1 TO wa_file.

IF NOT ( wa_file-flag = 'X' OR wa_file-flag = 'x' ) .
******************************************************
**MDO-008
******************************************************

  • LOOP AT I_CONTENTTAB1 INTO WA_CONTENTTAB1.
  • IF SY-TABIX = 1.
  • wa_contenttab2 = wa_contenttab1.
  • append wa_contenttab2 to i_contenttab2.
  • clear: wa_contenttab2.
  • ENDIF.
  • ENDLOOP.
    ******************************************************
    **MOD-008
    ******************************************************

LOOP AT I_CONTENTTAB1 INTO WA_CONTENTTAB1.
L_TABIX = SY-TABIX.
IF L_TABIX = 1.
wa_contenttab2 = wa_contenttab1.
append wa_contenttab2 to i_contenttab2.
clear: wa_contenttab2.
clear: l_tabix.
continue.
ENDIF.
ENDLOOP.

  • IF L_TABIX > 1.
    READ TABLE I_CONTENTTAB2 INTO WA_CONTENTTAB2 INDEX 1.
  • WITH KEY VTNAM = WA_CONTENTTAB1-VTNAM BINARY SEARCH.
    *****************************************************
    *MOD-008
    *****************************************************
    IF SY-SUBRC = 0.
    if not WA_CONTENTTAB2-CHAR1 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR1.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR2 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR2.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR3 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR3.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR4 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR4.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR5 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR5.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR6 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR6.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR7 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR7.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR8 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR8.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR9 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR9.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR10 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR10.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR11 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR11.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR12 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR12.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR13 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR13.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR14 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR14.
    APPEND wa_charname TO i_charname.
    endif.
    if not WA_CONTENTTAB2-CHAR15 is initial.
    wa_charname-name = WA_CONTENTTAB2-CHAR15.
    APPEND wa_charname TO i_charname.
    endif.
    ENDIF.
    *****************************************************
    *MOD-008
    *****************************************************
  • ENDIF.
  • ENDLOOP.
    *****************************************************
    *MOD-008
    *****************************************************
    SORT I_CHARNAME BY NAME.
    DELETE ADJACENT DUPLICATES FROM I_CHARNAME COMPARING NAME.
    DELETE I_CHARNAME WHERE NAME IS INITIAL.
    APPEND wa_file TO i_file.
    cLEAR: WA_FILE.
    ELSE.
    APPEND wa_file TO i_file_tmp.
    CLEAR: WA_FILE.
  • Check duplicate columns for characteristics
    PERFORM sub_dupl_columns.
    ENDIF.

ENDFORM. " SUB_STORE_FILE
&---------------------------------------------------------------------
*& Form SUB_GET_FILE
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • <--P_P_FNAME text
    ----------------------------------------------------------------------
    FORM SUB_GET_FILE. " CHANGING P_P_FNAME. "#EC NEEDED

DATA: C_FNH_MASK TYPE DXFIELDS-FILEMASK VALUE '.',
SEARCH_DIR TYPE DXFIELDS-LONGPATH VALUE '/usr/sap/trans/',
FILE_PATH LIKE DXFIELDS-LONGPATH.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
I_LOCATION_FLAG = 'A'
I_SERVER = ' '
I_PATH = SEARCH_DIR
FILEMASK = C_FNH_MASK
FILEOPERATION = 'R'
IMPORTING
O_PATH = FILE_PATH
EXCEPTIONS
RFC_ERROR = 1
OTHERS = 2.

IF SY-SUBRC EQ 0.
P_fname = FILE_PATH. "#EC
ENDIF.

ENDFORM. " SUB_GET_FILE
&---------------------------------------------------------------------
*& Form SUB_GET_FILE1
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • <--P_P_FNAME1 text
    ----------------------------------------------------------------------
    FORM SUB_GET_FILE1. " CHANGING P_P_FNAME1. "#EC NEEDED

DATA: C_FNH_MASK TYPE DXFIELDS-FILEMASK VALUE '.',
SEARCH_DIR TYPE DXFIELDS-LONGPATH VALUE '/usr/sap/trans/',
FILE_PATH LIKE DXFIELDS-LONGPATH.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
I_LOCATION_FLAG = 'A'
I_SERVER = ' '
I_PATH = SEARCH_DIR
FILEMASK = C_FNH_MASK
FILEOPERATION = 'R'
IMPORTING
O_PATH = FILE_PATH
EXCEPTIONS
RFC_ERROR = 1
OTHERS = 2.

IF SY-SUBRC EQ 0.
P_fname1 = FILE_PATH. "#EC
ENDIF.

ENDFORM. " SUB_GET_FILE1
&---------------------------------------------------------------------
*& Form SUB_APP_LOG_INIT
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • <--P_V_LOG_HANDLE text
    ----------------------------------------------------------------------
    Form SUB_APP_LOG_INIT CHANGING fp_log_handle TYPE balloghndl.

DATA: l_s_log TYPE bal_s_log. "#EC NEEDED

CLEAR l_s_log.

  • IS_LOG_HEADER-EXTNUMBER = TEXT-L01.
    IS_LOG_HEADER-ALUSER = SY-UNAME.
    IS_LOG_HEADER-ALDATE = SY-DATUM.
    IS_LOG_HEADER-ALTIME = SY-UZEIT.
    IS_LOG_HEADER-ALTCODE = IV_TCODE.
    IS_LOG_HEADER-ALPROG = SY-REPID.
    IS_LOG_HEADER-OBJECT = 'CAPI'.
    IS_LOG_HEADER-SUBOBJECT = 'CAPI_LOG'.
    is_log_header-del_before = 'X'.

CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = is_log_header
IMPORTING
e_log_handle = fp_log_handle
EXCEPTIONS
log_header_inconsistent = 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. " f_app_log_init

&---------------------------------------------------------------------
*& Form SUB_APP_LOG_INIT
&---------------------------------------------------------------------

FORM sub_app_log_add USING fp_log_handle TYPE balloghndl.

DATA: l_v_probclass TYPE bal_s_msg-probclass,
l_s_msg TYPE bal_s_msg,
l_v_msg TYPE boolean. "#EC NEEDED

  • priority clas
    CONSTANTS:
    l_c_probclass_very_high TYPE bal_s_msg-probclass VALUE '1',
    l_c_probclass_high TYPE bal_s_msg-probclass VALUE '2',
    l_c_probclass_medium TYPE bal_s_msg-probclass VALUE '3',
    l_c_probclass_low TYPE bal_s_msg-probclass VALUE '4',
    l_c_probclass_none TYPE bal_s_msg-probclass VALUE ' '.
  • message types
    CONSTANTS:
    l_c_msgty_x TYPE sy-msgty VALUE 'X',
    l_c_msgty_a TYPE sy-msgty VALUE 'A',
    l_c_msgty_e TYPE sy-msgty VALUE 'E',
    l_c_msgty_w TYPE sy-msgty VALUE 'W',
    l_c_msgty_i TYPE sy-msgty VALUE 'I',
    l_c_msgty_s TYPE sy-msgty VALUE 'S',
    l_c_msgty_none TYPE sy-msgty VALUE ' '.
    • entry check
  • CHECK sy-msgno NE 0.
  • CHECK sy-msgid NE space.
    • define data of message for Application Log
  • l_s_msg-msgty = sy-msgty.
  • l_s_msg-msgid = sy-msgid.
  • l_s_msg-msgno = sy-msgno.
  • l_s_msg-msgv1 = sy-msgv1.
  • l_s_msg-msgv2 = sy-msgv2.
  • l_s_msg-msgv3 = sy-msgv3.
  • l_s_msg-msgv4 = sy-msgv4.

******************************************
*MOD-009
******************************************
CLEAR: WA_ERROR_TAB.
CLEAR: L_S_MSG.

LOOP AT G_ERROR_TAB INTO WA_ERRORTAB.
l_s_msg-msgty = WA_ERRORTAB-msgty.
l_s_msg-msgid = WA_ERRORTAB-id.
l_s_msg-msgno = WA_ERRORTAB-msgno.
l_s_msg-msgv1 = WA_ERRORTAB-par1.
l_s_msg-msgv2 = WA_ERRORTAB-par2.
l_s_msg-msgv3 = WA_ERRORTAB-par3.
l_s_msg-msgv4 = WA_ERRORTAB-par4.
ENDLOOP.

  • CASE sy-msgty.
    CASE l_s_msg-msgty.
    WHEN l_c_msgty_x.
    l_v_probclass = l_c_probclass_very_high. l_v_msg = 'X'.
    WHEN l_c_msgty_a.
    l_v_probclass = l_c_probclass_very_high. l_v_msg = 'X'.
    WHEN l_c_msgty_e.
    l_v_probclass = l_c_probclass_high. l_v_msg = 'X'.
    WHEN l_c_msgty_w.
    l_v_probclass = l_c_probclass_medium.
    WHEN l_c_msgty_i.
    l_v_probclass = l_c_probclass_low.
    WHEN l_c_msgty_s.
    l_v_probclass = l_c_probclass_low.
    WHEN l_c_msgty_none.
    l_v_probclass = l_c_probclass_none.
    ENDCASE.
  • bis hier temporär
    l_s_msg-probclass = l_v_probclass.
  • add this message to log file

CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = fp_log_handle
i_s_msg = l_s_msg
EXCEPTIONS
log_not_found = 1
msg_inconsistent = 2
log_is_full = 3
OTHERS = 4.

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. " f_app_log_add
&---------------------------------------------------------------------
*& Form f_data_save
&---------------------------------------------------------------------

  • Saving the app log
    ----------------------------------------------------------------------
  • --> FP_LOG_HANDLE Variable
    ----------------------------------------------------------------------
    FORM sub_data_save USING fp_log_handle TYPE balloghndl.

DATA: lt_log_handle TYPE bal_t_logh.

APPEND fp_log_handle TO lt_log_handle.

CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_client = sy-mandt
i_save_all = ' '
i_t_log_handle = lt_log_handle
EXCEPTIONS
log_not_found = 1
save_not_allowed = 2
numbering_error = 3
OTHERS = 4.

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. " f_data_save

&---------------------------------------------------------------------
*& Form f_data_save
&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form SUB_CREATE_ERORTAB
&---------------------------------------------------------------------

  • text
    ----------------------------------------------------------------------
  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM SUB_CREATE_ERORTAB .

LOOP AT G_ERROR_TAB INTO WA_ERRORTAB.
concatenate WA_ERRORTAB-msgty
WA_ERRORTAB-id
WA_ERRORTAB-msgno
WA_ERRORTAB-par1
WA_ERRORTAB-par2
WA_ERRORTAB-par3
WA_ERRORTAB-par4
into wa_error_tab-line separated by space.
APPEND WA_ERROR_TAB TO I_ERRORTAB.
CLEAR: WA_ERROR_TAB, wa_errortab.
ENDLOOP.

ENDFORM. " SUB_CREATE_ERORTAB
&---------------------------------------------------------------------
*& Form BAL_DB_SAVE
&---------------------------------------------------------------------
FORM sub_log_show USING fp_log_handle TYPE balloghndl. "#EC NEEDED

DATA: LS_PROFILE TYPE BAL_S_PROF.

CALL FUNCTION 'BAL_DSP_PROFILE_SINGLE_LOG_GET'
IMPORTING
E_S_DISPLAY_PROFILE = LS_PROFILE.

  • we therefore show all messages immediately
    LS_PROFILE-EXP_LEVEL = 0.
    LS_PROFILE-USE_GRID = C_X.

CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
I_S_DISPLAY_PROFILE = LS_PROFILE
EXCEPTIONS
OTHERS = 1.
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. " LOG_DISPLAY
&---------------------------------------------------------------------
*& Form BAL_DB_SAVE
&---------------------------------------------------------------------

*Messages
*----------------------------------------------------------
*

  • Message class: /SAPDMC/LSMW
    *810 No partner exists with the name '&', type '&'
    *811 Create a partner profile for message type '&'
    *
  • Message class: ZFACTGLB
    *088
    *144
    *196
    *197
    *237
    *241
    *242
    *243
    *246