Project - ERP-MES Interface


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-02-2013
Tools Project - ERP-MES Interface

Hi all,

that's my personal "war story" and probably a beginning of a never ending love story.

It is roughly 8 weeks ago, I've got a training for a new ERP system. In front of the training my boss mentioned it based on a unix. Great, I have been always interested in but I don't know why I haven't invest time in it. Anyway, the training was great and it has awaken my passion.

Now, I try to invest every second to get more knowledge and especially the shell scripting and programming brings my heart to beat. That's the love story

Back to my "war story". I am responsible for testing the interface between an ERP and MES System. The problem it takes ages to get test data in order to verify it. Supplier pushed out deliveries for months. Honestly, supplier has a lot of more important stuff to do in order to get the ERP System running but I HAVE TO TEST THE INTERFACE. Hence, I've decided to write a shell script in order to simulate the interface communication and begin testing. My intention is to post the result and share result in this forum. (probably other rookies like me will get benefit)

ERP-MES Interface:

Output: UTF-8 file (without Byte Order Mark)

Content of UTF File: string (1000 digits) & CR & LF
- Creation of UTF FIle via BASH Script

Content of BASH Script:
- function to modify variabels (numeric, decimal, character)
- merge all variables to one string
- create UTF File with string

1. Question regarding the result of variable output (quoted/unquoted) --> https://www.unix.com/shell-programmin...-function.html
2. Question regarding formatting decimal value --> https://www.unix.com/shell-programmin...#post302780189

Code:
#!/bin/bash
fct_var_mod() {
        case "$1" in

        "C")    if [ ${#2} -eq "$3" ]
                then    value="$2"
                else    value="$(printf "%-$3.$3s" "$2")"
                fi;;
        "N")    value="$(printf "%0$3d" "$2" )"
        value="$(printf "%.$3s" "$value" )";;
        "D")    value="$(printf "%-$3.$3s" "$2" )"
        value="$(printf "%+0$3.$4f" "$value")";;
        esac
}
order_no_t=C; order_no=ORDER005-010010; order_no_l=40
fct_var_mod $order_no_t $order_no $order_no_l
order_no="$value"; echo "$order_no"
proc_no_T=N; proc_no=1283; proc_no_l=8
fct_var_mod $proc_no_T $proc_no $proc_no_l
proc_no="$value"; echo "$proc_no"
qty_t=D; qty_val=-12345678.123; qty_l=13; qty_p=3
fct_var_mod $qty_t $qty_val $qty_l $qty_p
qty_val="$value"; echo "$qty_val"

Diary:
2nd of March 2013 - Let's go
3rd of March 2013 - got great comments from Don Cragun
4th of March 2013 - added comments and mods from Don Cragun to basic post (#1)
14th of March 2013 - added formatting numeric and decimal values

Last edited by Noobie1995; 03-14-2013 at 07:16 AM.. Reason: cumulative editing
# 2  
Old 03-02-2013
I have no idea what you're trying to do and the variable names don't make any sense to me, but the following is a reformatted, simplified version of your script that is a valid bash script (and is easier for humans to read) that produces some output that may be what you want:
Code:
#!/bin/bash
fkt_auffuellen() {
        case $1 in
        (C)     if [ ${#2} -eq "$3" ]
                then    value="$2"
                else    value="$(printf "%-$3.$3s" "$2")"
                fi;;
        (N)     ;;
        (D)     ;;
        esac
}
vorg_nr_t=C
vorg_nr="AUFTRAG005-010010"
vorg_nr_l=40
fkt_auffuellen $vorg_nr_t $vorg_nr $vorg_nr_l
vorg_nr="$value"
echo "$vorg_nr"

Note that some double-quotes were added and others were removed, an if statement was removed by changing the printf format string, and I added opening parentheses to the case matching patterns. (The opening parentheses are allowed but are not required by bash, but if you're editing a larger script with an editor such as vi with a showmatch option, having them makes it much easier to find mismatched parentheses in places where they do matter.)

Hope this helps.
This User Gave Thanks to Don Cragun For This Post:
Noobie1995 (03-03-2013)
# 3  
Old 03-03-2013
Lightbulb

Good evening or should I say good morning,

I am so sorry I have no idea why my pasted code shows this terrible format. Probably, human error.

I agree with comments that variables names makes no sense. These are still in german. I will edit it tomorrow.

The idea to fill the string and if the lenghth is already longer than passed in the function to cut the string is great!!!!!

I will also try to highlight the intention of this project tomorrow. As mentioned it is my first one.

Many Thanks

Noobie1995
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
A new project was posted on The UNIX and Linux Forums project board. Neo News, Links, Events and Announcements 0 06-08-2013 10:18 AM
Adding a network interface to a bonded interface westmoreland UNIX for Dummies Questions & Answers 1 04-09-2013 05:36 PM
ERP - MES Interface - several function Noobie1995 Shell Programming and Scripting 5 03-02-2013 04:36 PM
Need a bridge from an ethernet interface to a serial interface mghis IP Networking 3 10-25-2010 03:38 PM
CK-ERP (Open Source Edu / ERP / CRM / MRP) v.0.30.1 released chiukay UNIX and Linux Applications 0 09-28-2010 04:13 AM
Change SCO - GUI or Desktop interface to DOS based interface TinhNhi SCO 2 09-17-2010 01:18 PM
Command line Interface or GUI Interface not shown on solaris mbouster Solaris 2 07-23-2010 03:16 PM
Compilation problem with Posix Mes Q kumaran_5555 Programming 4 05-19-2010 06:54 AM
Command 'rm -f -r "0yfOYy-0008Nq-2j-32233-K"' failed with return code 1 and error mes linuxbee UNIX for Dummies Questions & Answers 3 05-14-2009 05:00 PM
Linux based Open Source ERP System - CK-ERP chiukay UNIX and Linux Applications 0 06-25-2008 03:46 AM
SSH doesn't pick up user's project from /etc/project kurgan Solaris 2 05-21-2008 01:52 PM
About CK ERP hakim19 UNIX and Linux Applications 1 03-10-2008 10:15 PM