FII011 memory

//Sort the incoming items for each depend on the corresponding Check Number
for l_nCounter% = 1 to g_DetailCounter%
    for l_mCounter% = 1 to g_DetailCounter% - l_nCounter%
        if d_CheckNumber$[l_mCounter%] &> d_CheckNumber$[l_mCounter%+1]
            l_TempCheckNumber$ = d_CheckNumber$[l_mCounter%];
            l_TempVendorId$ = d_VendorId$[l_mCounter%];
            l_TempInvoiceDate$ = d_InvoiceDate$[l_mCounter%];
            l_TempInvoiceNumber$ = d_InvoiceNumber$[l_mCounter%];
            l_TempInvoiceAmount% = d_InvoiceAmount%[l_mCounter%];
            d_CheckNumber$[l_mCounter%] = d_CheckNumber$[l_mCounter%+1];
            d_VendorId$[l_mCounter%] = d_VendorId$[l_mCounter%+1];
            d_InvoiceDate$[l_mCounter%] = d_InvoiceDate$[l_mCounter%+1];
            d_InvoiceNumber$[l_mCounter%] = d_InvoiceNumber$[l_mCounter%+1];
            d_InvoiceAmount%[l_mCounter%] = d_InvoiceAmount%[l_mCounter%+1];
            d_CheckNumber$[l_mCounter%+1] = l_TempCheckNumber$;
            d_VendorId$[l_mCounter%+1] = l_TempVendorId$;
            d_InvoiceDate$[l_mCounter%+1] = l_TempInvoiceDate$;
            d_InvoiceNumber$[l_mCounter%+1] = l_TempInvoiceNumber$;
            d_InvoiceAmount%[l_mCounter%+1] = l_TempInvoiceAmount%;
        endif
    next
next


local l_LB2Counter%;
local l_PU1Counter%;
local l_iCounter%;
local l_Temp$;
local l_First$;
l_LB2Counter% = 1;
l_PU1Counter% = 1;
copy g_TotalInvoiceAmount$ to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB1:AMTTOTAL;

//Initiate the previous check number
l_Temp$ = "";
//define the flag for first item
l_First$ = "T";

//Initiate the sum invoice amount with the first one
d_SumInvoiceAmount% = d_InvoiceAmount%[1];

traceln("g_DetailCounter% asssgin to for loop is : " & g_DetailCounter%);

traceln("-------------------Start the mapping of segment EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2----------------------");
for l_iCounter% = 1 to g_DetailCounter%
    //if it's the first detail depend on the checkNumber
    if l_First$ &!= "T"
        //if the current CheckNumber is equal with the previous one
        if l_Temp$ &= d_CheckNumber$[l_iCounter%]    
            l_PU1Counter% = l_PU1Counter% + 1;
            d_SumInvoiceAmount% = d_SumInvoiceAmount% + d_InvoiceAmount%[l_iCounter%];
        //if the current CheckNumber is not equal with the previous one
        else
            l_LB2Counter% = l_LB2Counter% + 1;
            l_PU1Counter% = 1;
            overwrite d_SumInvoiceAmount% to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%-1]:AMTTOTAL;
            overwrite d_SumInvoiceAmount% to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%-1].E1IDQU5:MOABETR;
            d_SumInvoiceAmount% = d_InvoiceAmount%[l_iCounter%];
        endif
    endif
l_First$ = "F";
l_Temp$ = d_CheckNumber$[l_iCounter%];

    overwrite "001" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%]:BATBATNO;
    overwrite d_SumInvoiceAmount% to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%]:AMTTOTAL;
    overwrite "000001" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%]:SEQNUMBER;
    overwrite "AG" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDPA1:PARVW;
    overwrite d_VendorId$[l_iCounter%] to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDPA1:LIFNR;
    overwrite "026" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ02:QUALF;
    overwrite d_CheckNumber$[l_iCounter%] to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ02:BELNR;
  
    if g_CheckDate$ <> ""
        overwrite g_CheckDate$ to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ02:DATUM;
    //if CHECK-DATE is blank
    else
        overwrite currentDate()to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ02:DATUM;
    endif

    overwrite "017" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ03:IDDAT;

    if g_CheckDate$ <> ""
        overwrite g_CheckDate$ to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ03:DATUM;
        //if CHECK-DATE is blank
    else
        overwrite currentDate()to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1EDQ03:DATUM;
    endif
    overwrite "012" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDQU5:MOAQUAL;
    overwrite d_SumInvoiceAmount% to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDQU5:MOABETR;
   
traceln("----------Start mapping of Segment:EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2.E1IDPU1-----------");
     
    if d_InvoiceAmount%[l_iCounter%] > 0
        copy "INV" to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%]:DOCNAME;
    //if :INVOICE-AMOUNT is less than or equal to 0
    else
        copy "CRM" to  EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%]:DOCNAME;
    endif
    copy d_InvoiceNumber$[l_iCounter%] to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%]:DOCNUMMR;
    copy currentDate() to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%]:DOCDATUM;
    copy "006" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1IDRU5:MOAQUAL;
    copy d_InvoiceAmount%[l_iCounter%] to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1IDRU5:MOABETR;
       
    copy "017" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1EDR03:IDDAT;
    copy formatDate(d_InvoiceDate$[l_iCounter%],"MMddyy","yyyyMMdd") to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1EDR03:DATUM;
    copy currentTime() to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1EDR03:UZEIT;
   
    copy "010" to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1EDR02:QUALF;
    copy d_InvoiceNumber$[l_iCounter%] to EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2[l_LB2Counter%].E1IDPU1[l_PU1Counter%].E1EDR02:BELNR;

traceln("----------End mapping of Segment:EDI_DC40.E1IDKU1.E1IDPF1.E1IDLB2.E1IDPU1-----------");
next

你可能感兴趣的:(F#)